Passed
Push — master ( ed1281...662d52 )
by eXeCUT
03:45
created

components/source/adapter/Ftp.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: execut
5
 * Date: 9/28/16
6
 * Time: 4:45 PM
7
 */
8
9
namespace execut\import\components\source\adapter;
10
11
12
use execut\import\components\source\Adapter;
13
use execut\import\components\source\File;
14
use yii\base\Component;
15
use yii2mod\ftp\FtpClient;
0 ignored issues
show
The type yii2mod\ftp\FtpClient 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...
16
17
class Ftp extends Adapter
18
{
19
    public $host = null;
20
    public $ssl = false;
21
    public $port = 21;
22
    public $timeout = 90;
23
    public $login = null;
24
    public $password = null;
25
    public $dir = null;
26
    public $fileName = null;
27
    protected $client = null;
28 1
    public function getFiles() {
29 1
        $client = $this->getClient();
30 1
        $file = $this->createFile($this->fileName);
31
32 1
        $client->connect($this->host, $this->ssl, $this->port, $this->timeout);
33 1
        $client->login($this->login, $this->password);
34 1
        $client->raw('OPTS UTF8 ON');
35 1
        $client->pasv(true);
36 1
        $client->get($file->filePath, trim($this->dir, '/') . '/' . $this->fileName, FTP_BINARY);
37
38
        return [
39 1
            $file,
40
        ];
41
    }
42
43 1
    public function setClient($client) {
44 1
        $this->client = $client;
45 1
        return $this;
46
    }
47
48 1
    public function getClient() {
49 1
        if ($this->client !== null) {
50 1
            return $this->client;
51
        }
52
53
        $client = new FtpClient();
54
55
        return $this->client = $client;
56
    }
57
}