PutRemoteFileAs   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 31
c 0
b 0
f 0
ccs 0
cts 12
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 0 3 1
A handle() 0 11 2
1
<?php
2
3
namespace Freyo\Flysystem\QcloudCOSv4\Plugins;
4
5
use League\Flysystem\Plugin\AbstractPlugin;
6
7
class PutRemoteFileAs extends AbstractPlugin
8
{
9
    /**
10
     * Get the method name.
11
     *
12
     * @return string
13
     */
14
    public function getMethod()
15
    {
16
        return 'putRemoteFileAs';
17
    }
18
19
    /**
20
     * @param       $path
21
     * @param       $remoteUrl
22
     * @param       $name
23
     * @param array $options
24
     *
25
     * @return bool
26
     */
27
    public function handle($path, $remoteUrl, $name, array $options = [])
28
    {
29
        //Get file from remote url
30
        $contents = (new \GuzzleHttp\Client(['verify' => false]))
31
            ->request('get', $remoteUrl)
32
            ->getBody()
33
            ->getContents();
34
35
        $path = trim($path.'/'.$name, '/');
36
37
        return $this->filesystem->put($path, $contents, $options) ? $path : false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->filesystem...ptions) ? $path : false also could return the type string which is incompatible with the documented return type boolean.
Loading history...
38
    }
39
}
40