1 | <?php |
||
6 | class Ftp |
||
7 | { |
||
8 | const DRIVER = 'driver'; |
||
9 | protected $driver; |
||
10 | protected $params = array(); |
||
11 | private $driverInstance = null; |
||
12 | |||
13 | /** |
||
14 | * @var Factory |
||
15 | */ |
||
16 | private $factory; |
||
17 | |||
18 | 9 | public function __construct($params = array()) |
|
23 | |||
24 | /** |
||
25 | * @return Ftp\FtpInterface |
||
26 | * @throws Ftp\Exception |
||
27 | */ |
||
28 | 1 | public function getDriver() |
|
29 | { |
||
30 | 1 | if (!is_null($this->driverInstance)) { |
|
31 | 1 | return $this->driverInstance; |
|
32 | } |
||
33 | |||
34 | 1 | $driverInstance = $this->getFactory()->create($this->driver, $this->params); |
|
35 | 1 | $this->driverInstance = $driverInstance; |
|
36 | 1 | return $this->driverInstance; |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return Factory |
||
41 | */ |
||
42 | 2 | public function getFactory() |
|
49 | |||
50 | /** |
||
51 | * @param Factory $factory |
||
52 | * @return $this |
||
53 | */ |
||
54 | 1 | public function setFactory(Factory $factory) |
|
59 | |||
60 | /** |
||
61 | * @param string $host |
||
62 | * @param int $port |
||
63 | * @return $this |
||
64 | */ |
||
65 | 1 | public function connect($host, $port = 21) |
|
70 | |||
71 | /** |
||
72 | * @param string $user |
||
73 | * @param string $pass |
||
74 | * @return bool |
||
75 | */ |
||
76 | 1 | public function login($user, $pass) |
|
80 | |||
81 | /** |
||
82 | * @param string $localFile |
||
83 | * @param string $remoteFile |
||
84 | * @return bool |
||
85 | */ |
||
86 | 1 | public function get($localFile, $remoteFile) |
|
90 | |||
91 | /** |
||
92 | * @param string $remoteFile |
||
93 | * @param string $localFile |
||
94 | * @return bool |
||
95 | */ |
||
96 | 1 | public function put($remoteFile, $localFile) |
|
100 | |||
101 | /** |
||
102 | * @param $file |
||
103 | * @return bool |
||
104 | */ |
||
105 | 1 | public function delete($file) |
|
109 | |||
110 | /** |
||
111 | * @return bool |
||
112 | */ |
||
113 | 1 | public function close() |
|
117 | } |
||
118 |