This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
5
{
6
const DRIVER_FTP = 'Ftp';
7
const DRIVER_SFTP = 'Sftp';
8
const DRIVER_FTP_IMPLICIT_SSL = 'FtpImplicitSSL';
9
10
private static $instance;
11
12
1
private function __construct()
13
{
14
1
}
15
16
/**
17
* Design pattern Singleton
18
* @codeCoverageIgnore
19
*/
20
private function __clone()
21
{
22
}
23
24
/**
25
* @return self
26
*/
27
4
final public static function getInstance()
28
{
29
4
if (!self::$instance) {
30
1
$class = get_called_class();
31
1
self::$instance = new $class;
32
}
33
4
return self::$instance;
34
}
35
36
/**
37
* @param string $driver
38
* @param array $params
39
* @return FtpInterface
40
* @throws Exception
41
*/
42
4
final public function create($driver = self::DRIVER_FTP, $params = array())
43
{
44
4
$class = $this->getClassNameForDriver($driver);
45
4
if (!class_exists($class)) {
46
1
throw new Exception('Unable to create ' . $class);
47
}
48
3
$instance = new $class($params);
49
3
if (!$instance instanceof FtpInterface) {
50
1
throw new Exception('Unable to create ' . $class);
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.