PutRemoteFile   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 2
A getMethod() 0 3 1
1
<?php
2
/**
3
 * Created by jacob.
4
 * User: jacob
5
 * Date: 16/5/20
6
 * Time: 下午8:31
7
 */
8
namespace Jacobcyl\AliOSS\Plugins;
9
use League\Flysystem\Config;
0 ignored issues
show
Bug introduced by
The type League\Flysystem\Config was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use League\Flysystem\Plugin\AbstractPlugin;
0 ignored issues
show
Bug introduced by
The type League\Flysystem\Plugin\AbstractPlugin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
class PutRemoteFile extends AbstractPlugin
12
{
13
    /**
14
     * Get the method name.
15
     *
16
     * @return string
17
     */
18
    public function getMethod()
19
    {
20
        return 'putRemoteFile';
21
    }
22
23
    public function handle($path, $remoteUrl, array $options = []){
24
        $config = new Config($options);
25
        if (method_exists($this->filesystem, 'getConfig')) {
26
            $config->setFallback($this->filesystem->getConfig());
27
        }
28
29
        //Get file stream from remote url
30
        $resource = fopen($remoteUrl, 'r');
31
32
        return (bool)$this->filesystem->getAdapter()->writeStream($path, $resource, $config);
33
    }
34
}
35