1 | <?php |
||
13 | class Ftp implements AdapterInterface |
||
14 | { |
||
15 | const FTP_MODE_ASCII = FTP_ASCII; |
||
16 | const FTP_MODE_BINARY = FTP_BINARY; |
||
17 | |||
18 | protected $host = ''; |
||
19 | protected $username = ''; |
||
20 | protected $password = ''; |
||
21 | protected $filename = ''; |
||
22 | protected $port = 21; |
||
23 | |||
24 | protected $timeout = 90; |
||
25 | protected $handle = null; |
||
26 | |||
27 | /** |
||
28 | * You might think just connect to the ftp server from the constructor |
||
29 | * but psr-4 dictates that autoloadable classes MUST NOT... |
||
30 | * |
||
31 | * Quote: |
||
32 | * Autoloader implementations MUST NOT throw exceptions, MUST NOT raise errors of any level, and SHOULD NOT return a value. |
||
33 | * |
||
34 | * So we need to use authenticate() after we construct. |
||
35 | * |
||
36 | * @param string $host |
||
37 | * @param string $username |
||
38 | * @param string $password |
||
39 | * @param string $filename |
||
40 | * @param int $port |
||
41 | * @param int $timeout |
||
42 | */ |
||
43 | public function __construct($host = "", $username = "", $password = "", $filename = "", $port = 21, $timeout = 90) |
||
52 | |||
53 | /** |
||
54 | * We should be so nice to terminate the construction of we are done. |
||
55 | */ |
||
56 | public function __destruct() |
||
62 | |||
63 | /** |
||
64 | * Authenticate to the ftp server. |
||
65 | * |
||
66 | * @return bool |
||
67 | */ |
||
68 | public function authenticate() |
||
90 | |||
91 | /** |
||
92 | * Read the previous scan results from the file system. |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | public function read() |
||
122 | |||
123 | /** |
||
124 | * Write the report to the filesystem so we can reuse it |
||
125 | * at a later stace when we invoke Redbox\Scan\ScanService's scan() method. |
||
126 | * |
||
127 | * @param Report\Report|null $report |
||
128 | * @return bool |
||
129 | */ |
||
130 | public function write(Report\Report $report = null) |
||
153 | } |