Issues (14)

src/Plugins/PutRemoteFileAs.php (1 issue)

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