PutRemoteFileAs   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 33
ccs 0
cts 14
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 2
A getMethod() 0 3 1
1
<?php
2
3
namespace Freyo\Flysystem\QcloudCOSv5\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 string|false
26
     */
27
    public function handle($path, $remoteUrl, $name, array $options = [])
28
    {
29
        //Get file from remote url
30
        $contents = $this->filesystem
31
            ->getAdapter()
32
            ->getHttpClient()
33
            ->get($remoteUrl)
34
            ->getBody()
35
            ->getContents();
36
37
        $path = trim($path.'/'.$name, '/');
38
39
        return $this->filesystem->put($path, $contents, $options) ? $path : false;
40
    }
41
}
42