Completed
Push — master ( e7a951...39e8d7 )
by WEBEWEB
05:07
created

Authenticator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
/**
4
 * This file is part of the core-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\Core\Net;
13
14
use WBW\Library\Core\Exception\Argument\IllegalArgumentException;
15
16
/**
17
 * Authenticator.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Library\Core\Net
21
 */
22
class Authenticator {
23
24
    /**
25
     * Host.
26
     *
27
     * @var string
28
     */
29
    private $host;
30
31
    /**
32
     * Password authentication.
33
     *
34
     * @var PasswordAuthentication
35
     */
36
    private $passwordAuthentication;
37
38
    /**
39
     * Port.
40
     *
41
     * @var integer
42
     */
43
    private $port;
44
45
    /**
46
     * Constructor.
47
     *
48
     * @param string $host The host.
49
     * @param PasswordAuthentication $passwordAuthentication
50
     */
51
    public function __construct($host, PasswordAuthentication $passwordAuthentication) {
52
        $this->host                   = $host;
53
        $this->passwordAuthentication = $passwordAuthentication;
54
    }
55
56
    /**
57
     * Get the host.
58
     *
59
     * @return string Returns the host.
60
     */
61
    public function getHost() {
62
        return $this->host;
63
    }
64
65
    /**
66
     * Get the password authentication.
67
     *
68
     * @return PasswordAuthentication Returns this password authentication.
69
     */
70
    public function getPasswordAuthentication() {
71
        return $this->passwordAuthentication;
72
    }
73
74
    /**
75
     * Get the port.
76
     *
77
     * @return integer Returns the port.
78
     */
79
    public function getPort() {
80
        return $this->port;
81
    }
82
83
    /**
84
     * Set the host.
85
     *
86
     * @param string $host
87
     * @return Authenticator Returns this authenticator.
88
     */
89
    public function setHost($host) {
90
        $this->host = $host;
91
        return $this;
92
    }
93
94
    /**
95
     * Set the password authenticator.
96
     *
97
     * @param PasswordAuthentication $passwordAuthentication The password authentication.
98
     * @return Authenticator Returns this authenticator.
99
     */
100
    public function setPasswordAuthentication(PasswordAuthentication $passwordAuthentication) {
101
        $this->passwordAuthentication = $passwordAuthentication;
102
        return $this;
103
    }
104
105
    /**
106
     * Set the port.
107
     *
108
     * @param integer $port The port.
109
     * @return Authenticator Returns this authenticator.
110
     * @throws IllegalArgumentException Throws an illegal argument exception if the port isn't between 1 and 65536.
111
     */
112
    public function setPort($port) {
113
        if ($port < 1 || 65536 < $port) {
114
            throw new IllegalArgumentException("The port must be between 1 and 65536");
115
        }
116
        $this->port = $port;
117
        return $this;
118
    }
119
120
}
121