AbstractTransporter   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 198
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 42%

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 0
dl 0
loc 198
ccs 21
cts 50
cp 0.42
rs 10
c 0
b 0
f 0

24 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setOptions() 0 8 1
A setHost() 0 6 1
A getHost() 0 4 1
A setPort() 0 6 1
A getPort() 0 4 1
A setUser() 0 6 1
A getUser() 0 4 1
A setPass() 0 6 1
A getPass() 0 4 1
A setPath() 0 6 1
A getPath() 0 4 1
A getDispatcher() 0 4 1
A setDispatcher() 0 6 1
exists() 0 1 ?
mkdir() 0 1 ?
get() 0 1 ?
put() 0 1 ?
putContent() 0 1 ?
symlink() 0 1 ?
isSymlink() 0 1 ?
copy() 0 1 ?
remove() 0 1 ?
ls() 0 1 ?
1
<?php
2
3
/*
4
 * This file is part of the Conveyor package.
5
 *
6
 * (c) Jeroen Fiege <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webcreate\Conveyor\Transporter;
13
14
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15
16
abstract class AbstractTransporter
17
{
18
    protected $username;
19
    protected $password;
20
    protected $path;
21
    protected $host;
22
    protected $port;
23
24
    /**
25
     * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
26
     */
27
    protected $dispatcher;
28
29 30
    public function __construct(EventDispatcherInterface $dispatcher)
30
    {
31 30
        $this->setDispatcher($dispatcher);
32 30
    }
33
34
    public function setOptions(array $options)
35
    {
36
        $this->setHost($options['host']);
37
        $this->setPort($options['port']);
38
        $this->setUser($options['user']);
39
        $this->setPass($options['pass']);
40
        $this->setPath($options['path']);
41
    }
42
43 31
    public function setHost($host)
44
    {
45 31
        $this->host = $host;
46
47 31
        return $this;
48
    }
49
50 15
    public function getHost()
51
    {
52 15
        return $this->host;
53
    }
54
55
    /**
56
     * @param  mixed $port
57
     * @return self
58
     */
59
    public function setPort($port)
60
    {
61
        $this->port = $port;
62
63
        return $this;
64
    }
65
66
    /**
67
     * @return mixed
68
     */
69
    public function getPort()
70
    {
71
        return $this->port;
72
    }
73
74 31
    public function setUser($username)
75
    {
76 31
        $this->username = $username;
77
78 31
        return $this;
79
    }
80
81 15
    public function getUser()
82
    {
83 15
        return $this->username;
84
    }
85
86
    public function setPass($password)
87
    {
88
        $this->password = $password;
89
90
        return $this;
91
    }
92
93
    public function getPass()
94
    {
95
        return $this->password;
96
    }
97
98 36
    public function setPath($path)
99
    {
100 36
        $this->path = $path;
101
102 36
        return $this;
103
    }
104
105 32
    public function getPath()
106
    {
107 32
        return $this->path;
108
    }
109
110
    public function getDispatcher()
111
    {
112
        return $this->dispatcher;
113
    }
114
115 31
    public function setDispatcher(EventDispatcherInterface $dispatcher)
116
    {
117 31
        $this->dispatcher = $dispatcher;
118
119 31
        return $this;
120
    }
121
122
    /**
123
     * Checks if a file or directory exists on the remote server
124
     *
125
     * @param  string $path remote source path
126
     * @return bool   true when the resource exists, false otherwise
127
     */
128
    abstract public function exists($path);
129
130
    /**
131
     * Create a directory on the remote server
132
     *
133
     * @param string $dest remote path
134
     */
135
    abstract public function mkdir($dest);
136
137
    /**
138
     * Retrieve file or directory from remote server
139
     *
140
     * @param string $src  remote source path
141
     * @param string $dest (optional) local destination path
142
     */
143
    abstract public function get($src, $dest = null);
144
145
    /**
146
     * Upload a file or directory to remote server
147
     *
148
     * @param string $src  local source path
149
     * @param string $dest remote destination path
150
     */
151
    abstract public function put($src, $dest);
152
153
    /**
154
     * Upload a string to remote server
155
     *
156
     * @param string $content content
157
     * @param string $dest    remote destination path
158
     */
159
    abstract public function putContent($content, $dest);
160
161
    /**
162
     * Creates a symlink on the remote server
163
     *
164
     * @param string $src
165
     * @param string $dest
166
     * @return mixed
167
     */
168
    abstract public function symlink($src, $dest);
169
170
    /**
171
     * Checks for symlink on the remote server
172
     *
173
     * @param $dest
174
     * @return bool
175
     */
176
    abstract public function isSymlink($dest);
177
178
    /**
179
     * Copies a file/directory on the remote host
180
     *
181
     * @param  string $src
182
     * @param  string $dest
183
     * @param  bool   $recursive
184
     * @return mixed
185
     */
186
    abstract public function copy($src, $dest, $recursive = true);
187
188
    /**
189
     * Removes a file/directory on the remote host
190
     *
191
     * @param  string $path
192
     * @param  bool   $recursive
193
     * @return mixed
194
     */
195
    abstract public function remove($path, $recursive = true);
196
197
    /**
198
     * Lists files and directories on the remote host
199
     *
200
     * returns an array with the following format:
201
     *
202
     * array(
203
     *   'filename' => array(
204
     *     'type' => 'directory', // or 'file'
205
     *     'mtime' => new \DateTime(),
206
     *   ),
207
     * );
208
     *
209
     * @param  string $path
210
     * @return array
211
     */
212
    abstract public function ls($path);
0 ignored issues
show
Coding Style introduced by
This method's name is shorter than the configured minimum length of 3 characters.

Even though PHP does not care about the name of your methods, it is generally a good practice to choose method names which can be easily understood by other human readers.

Loading history...
213
}
214