None::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace LibSSH2\Authentication;
3
4
use LibSSH2\Configuration;
5
/**
6
 * None class.
7
 *
8
 * Username based authentication.
9
 *
10
 * @package LibSSH2\Authentication
11
 */
12
class None extends Configuration implements Authentication
13
{
14
    /**
15
     * Username.
16
     *
17
     * @var string
18
     */
19
    protected $username;
20
21
    /**
22
     * Constructor.
23
     *
24
     * @param  object $configuration Configuration object
25
     * @return void
26
     */
27
    public function __construct(Configuration $configuration)
28
    {
29
        $this->username = $configuration->get_username();
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    final public function authenticate($resource)
36
    {
37
        $auth = @ssh2_auth_none($resource, $this->username);
38
        if (is_array($auth))
39
        {
40
            throw new \RuntimeException('Username based authentication failed, supported methods include: ' . implode(', ', $auth));
41
        }
42
    }
43
}
44