Completed
Push — master ( ffad52...39a2da )
by WEBEWEB
01:36
created

AbstractFTPClient   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 76
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getAuthenticator() 0 3 1
A getConnection() 0 3 1
A newFTPException() 0 3 1
A setAuthenticator() 0 4 1
A setConnection() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the ftp-library package.
5
 *
6
 * (c) 2018 WEBEWEB
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 WBW\Library\FTP\Client;
13
14
use WBW\Library\Core\Security\Authenticator;
15
use WBW\Library\FTP\Exception\FTPException;
16
17
/**
18
 * Abstract FTP client.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Library\FTP\Client
22
 * @abstract
23
 */
24
abstract class AbstractFTPClient {
25
26
    /**
27
     * Authenticator.
28
     *
29
     * @var Authenticator
30
     */
31
    private $authenticator;
32
33
    /**
34
     * Connection.
35
     *
36
     * @var ressource
37
     */
38
    private $connection;
39
40
    /**
41
     * Constructor.
42
     *
43
     * @param Authenticator $authenticator The authenticator.
44
     */
45
    protected function __construct(Authenticator $authenticator) {
46
        $this->authenticator = $authenticator;
47
    }
48
49
    /**
50
     * Get the authenticator.
51
     *
52
     * @return Authenticator Returns the authenticator.
53
     */
54
    final public function getAuthenticator() {
55
        return $this->authenticator;
56
    }
57
58
    /**
59
     * Get the connection.
60
     *
61
     * @return resource Returns the connection.
62
     */
63
    final public function getConnection() {
64
        return $this->connection;
65
    }
66
67
    /**
68
     * Construct a new FTP exception.
69
     *
70
     * @param string $message The message.
71
     * @return FTPException Returns a new FTP exception.
72
     */
73
    final protected function newFTPException($message) {
74
        return new FTPException(sprintf("%s://%s:%s@%s:%d " . $message, $this->authenticator->getScheme(), $this->authenticator->getPasswordAuthentication()->getUsername(), $this->authenticator->getPasswordAuthentication()->getPassword(), $this->authenticator->getHost(), $this->authenticator->getPort()));
0 ignored issues
show
Bug introduced by
The method getScheme() does not seem to exist on object<WBW\Library\Core\Security\Authenticator>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
    }
76
77
    /**
78
     * Set the authenticator.
79
     *
80
     * @param \WBW\Library\FTP\Client\Authenticator $authenticator The authenticator.
81
     * @returns AbstractFTPClient Returns this abstract FTP client.
82
     */
83
    final protected function setAuthenticator(Authenticator $authenticator) {
84
        $this->authenticator = $authenticator;
85
        return $this;
86
    }
87
88
    /**
89
     * Set the connection.
90
     *
91
     * @param ressource $connection The connection.
92
     * @returns AbstractFTPClient Returns this abstract FTP client.
93
     */
94
    final protected function setConnection($connection) {
95
        $this->connection = $connection;
96
        return $this;
97
    }
98
99
}
100