Completed
Push — master ( 74c21e...559f84 )
by WEBEWEB
06:38
created

Authenticator::setScheme()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
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\Security;
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\Security
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
     * Scheme.
47
     *
48
     * @var string
49
     */
50
    private $scheme;
51
52
    /**
53
     * Constructor.
54
     *
55
     * @param string $host The host.
56
     * @param PasswordAuthentication $passwordAuthentication
57
     */
58
    public function __construct($host, PasswordAuthentication $passwordAuthentication) {
59
        $this->host                   = $host;
60
        $this->passwordAuthentication = $passwordAuthentication;
61
    }
62
63
    /**
64
     * Get the host.
65
     *
66
     * @return string Returns the host.
67
     */
68
    public function getHost() {
69
        return $this->host;
70
    }
71
72
    /**
73
     * Get the password authentication.
74
     *
75
     * @return PasswordAuthentication Returns this password authentication.
76
     */
77
    public function getPasswordAuthentication() {
78
        return $this->passwordAuthentication;
79
    }
80
81
    /**
82
     * Get the port.
83
     *
84
     * @return integer Returns the port.
85
     */
86
    public function getPort() {
87
        return $this->port;
88
    }
89
90
    /**
91
     * Get the scheme.
92
     *
93
     * @return string Returns the scheme.
94
     */
95
    public function getScheme() {
96
        return $this->scheme;
97
    }
98
99
    /**
100
     * Set the host.
101
     *
102
     * @param string $host
103
     * @return Authenticator Returns this authenticator.
104
     */
105
    public function setHost($host) {
106
        $this->host = $host;
107
        return $this;
108
    }
109
110
    /**
111
     * Set the password authenticator.
112
     *
113
     * @param PasswordAuthentication $passwordAuthentication The password authentication.
114
     * @return Authenticator Returns this authenticator.
115
     */
116
    public function setPasswordAuthentication(PasswordAuthentication $passwordAuthentication) {
117
        $this->passwordAuthentication = $passwordAuthentication;
118
        return $this;
119
    }
120
121
    /**
122
     * Set the port.
123
     *
124
     * @param integer $port The port.
125
     * @return Authenticator Returns this authenticator.
126
     * @throws IllegalArgumentException Throws an illegal argument exception if the port isn't between 1 and 65536.
127
     */
128
    public function setPort($port) {
129
        if ($port < 0 || 65536 < $port) {
130
            throw new IllegalArgumentException("The port must be between 1 and 65536");
131
        }
132
        $this->port = $port;
133
        return $this;
134
    }
135
136
    /**
137
     * Set the shceme.
138
     *
139
     * @param string $scheme The scheme.
140
     * @return Authenticator Returns this authenticator.
141
     */
142
    public function setScheme($scheme) {
143
        $this->scheme = $scheme;
144
        return $this;
145
    }
146
147
}
148