None   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authenticate() 0 6 2
A __construct() 0 3 1
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