Copy

@param string|resource $source
@param array           $settings = []

@return GD
485563
public function copy($source, Array $settings = []) : GD
    {
        if( is_file($file = $source) )
        {
            $source = $this->createFrom($source);
        }

        if( ! is_resource($source) )
        {
            throw new InvalidArgumentException(NULL, '[resource]');
        }

        $this->alignImageWatermark($file);

        $xt     = $settings['xt']     ?? $this->target[0] ?? 0;
        $yt     = $settings['yt']     ?? $this->target[1] ?? 0;
        $xs     = $settings['xs']     ?? $this->source[0] ?? 0;
        $ys     = $settings['ys']     ?? $this->source[1] ?? 0;
        $width  = $settings['width']  ?? $this->width     ?? 0;
        $height = $settings['height'] ?? $this->height    ?? 0;

        imagecopy($this->canvas, $source, $xt, $yt, $xs, $ys, $width, $height);
        
        $this->defaultRevolvingVariables();

        return $this;
    }
188891
public function crop(Array $settings = []) : GD
    {
        $sets = 
        [
            'x'      => $settings['x']      ?? $this->x      ?? 0,
            'y'      => $settings['y']      ?? $this->y      ?? 0,
            'width'  => $settings['width']  ?? $this->width  ?? 100,
            'height' => $settings['height'] ?? $this->height ?? 0,

        ];

        $this->canvas = imagecrop($this->canvas, $sets);

        $this->defaultRevolvingVariables();
        
        return $this;
    }
810152
public function set($settings) {

        if (!$this->simple) {
            if (is_a($this->source, 'ToolConsumer')) {
                $type = 'ToolProxy';
            } else if (is_a($this->source, 'ToolConsumer')) {
                $type = 'ToolProxyBinding';
            } else {
                $type = 'LtiLink';
            }
            $obj = new \stdClass();
            $obj->{'@context'} = 'http://purl.imsglobal.org/ctx/lti/v2/ToolSettings';
            $obj->{'@graph'} = array();
            $level = new \stdClass();
            $level->{'@type'} = $type;
            $level->{'@id'} = $this->endpoint;
            $level->{'custom'} = $settings;
            $obj->{'@graph'}[] = $level;
            $body = json_encode($obj);
        } else {
            $body = json_encode($settings);
        }

        $response = parent::send('PUT', null, $body);

        return $response->ok;

    }
1239947
public function createFrom(String $source, Array $settings = [])
    {
        $type = $this->mime->type($source, 1);

        switch( $type )
        {
            case 'gd2p'   : $return = imagecreatefromgd2part
            (
                $source,
                $settings['x']      ?? NULL,
                $settings['y']      ?? NULL,
                $settings['width']  ?? NULL,
                $settings['height'] ?? NULL
            ); 
            break;

            default: 
                $function = 'imagecreatefrom' . ($type ?? 'jpeg');
                $return   = $function($source);
        }

        return $return;
    }
1208790
public function setSource($source)
    {
        $array = $this->castToArray($source);

        foreach ($array as $item) {
            $this->append($item);
        }

        return $this;
    }
430471
public function copy($source, $overrides = [])
    {
        $this->sourceId = $source;
        return $this->sync($overrides) ? $this : null;
    }
158175
private function copyRecursive($source, $target)
    {
        if (!is_dir($source)) {
            $this->filesystem->ensureDirectoryExists(dirname($target));
            copy($source, $target);

            return;
        }

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $this->filesystem->ensureDirectoryExists($target);

        foreach ($iterator as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
            if ($file->isDir()) {
                $this->filesystem->ensureDirectoryExists($targetPath);
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
228178
public static function setup(Settings $settings, ConnectionInterface $connection = null)
    {
        return static::getInstance($settings)->load($connection);
    }
1257984
public function settings(Array $settings = []) : Upload
    {
        foreach( $settings as $key => $val )
        {
            $this->settings[$key] = $val;
        }

        return $this;
    }
416560
public function resize($source, Array $settings = []) : GD
    {
        $this->resample($source, $settings, 'imagecopyresized');

        return $this;
    }
1164142
public static function copy(String $source, String $target) : Bool
    {
        return Filesystem::copy(Info::rpath($source), Info::rpath($target));
    }
1090054
public static function copy($source, $target, $ignore = null)
    {
        $source = rtrim($source, '\\/');
        $target = rtrim($target, '\\/');

        if (!is_dir($source)) {
            throw new \RuntimeException('Cannot copy non-existing folder.');
        }

        // Make sure that path to the target exists before copying.
        self::create($target);

        $success = true;

        // Go through all sub-directories and copy everything.
        $files = self::all($source);
        foreach ($files as $file) {
            if ($ignore && preg_match($ignore, $file)) {
                continue;
            }
            $src = $source .'/'. $file;
            $dst = $target .'/'. $file;

            if (is_dir($src)) {
                // Create current directory (if it doesn't exist).
                if (!is_dir($dst)) {
                    $success &= @mkdir($dst, 0777, true);
                }
            } else {
                // Or copy current file.
                $success &= @copy($src, $dst);
            }
        }

        if (!$success) {
            $error = error_get_last();
            throw new \RuntimeException($error['message'] ?? 'Unknown error');
        }

        // Make sure that the change will be detected when caching.
        @touch(dirname($target));
    }
994711
protected function copy($source, $dest)
    {
        // Check for symlinks
        if ( is_link($source) ) {
            return symlink(readlink($source), $dest);
        }

        // Simple copy for a file
        if ( is_file($source) ) {

            if (!file_exists($dest)) {
                copy(
                    $source,
                    $dest
                );
                return;
            }

            copy($source, str_replace('.php', '.php.dist', $dest));
            return;
        }

        // Make destination directory
        if ( !is_dir($dest) ) {
            mkdir($dest);
        }

        // Loop through the folder
        $dir = dir($source);
        while (FALSE !== $entry = $dir->read()) {
            // Skip pointers
            if ( $entry == '.' || $entry == '..' ) {
                continue;
            }

            // Deep copy directories
            $this->copy("$source/$entry", "$dest/$entry");
        }

        // Clean up
        $dir->close();

        return TRUE;
    }
727439
protected function copyFile($source, $dest)
  {
    $dir  = dirname($dest);

    if (!is_dir($dir)) {
      mkdir($dir, 0777, true);
    }

    if (is_uploaded_file($source)) {
      $res = @move_uploaded_file($source, $dest);
    } else {
      $res = @copy($source, $dest);
    }

    if (!$res) {
      $err = error_get_last();

      Exception::ThrowError(Exception::PROCESSING_FILE, $err['message']);
    }
  }
674275
public function saveSettings($settings)
    {
        if (isset($settings['name']) && isset($this->config['servers'][$settings['name']])) {
            return $this->saveConfig(array_merge($this->config['servers'][$settings['name']], $settings));
        }
    }
665539
public static function copy(string $source, string $destination)
  {
    if (is_dir($source)) {
      @mkdir($destination);

      $directory = dir($source);

      while (false !== ($readdirectory = $directory->read())) {
        if ($readdirectory == '.' || $readdirectory == '..') {
          continue;
        }

        $PathDir = $source . '/' . $readdirectory;

        if (is_dir($PathDir)) {
          Filesystem::copy($PathDir, $destination . '/' . $readdirectory);
          continue;
        }
        copy($PathDir, $destination . '/' . $readdirectory);
      }

      $directory->close();
    } else {
      copy($source, $destination);
    }
  }
445230
public function addSetting($name, $settings, $key = null)
	{
		$value = $this->settingExists($name,$key) ? $this->getSetting($name, $key) : null;

		if(is_array($settings))
		{
			$settings = array_merge((array)$value, $settings);
		}

		if($key)
		{
			$this->_settings[$name][$key] = $settings;
		}
		else
		{
			$this->_settings[$name] = $settings;
		}

		return $this;
	}