Agent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authenticate() 0 5 2
A __construct() 0 3 1
1
<?php
2
namespace LibSSH2\Authentication;
3
4
use LibSSH2\Configuration;
5
6
/**
7
 * Agent class.
8
 *
9
 * SSH agent based authentication.
10
 *
11
 * @package LibSSH2\Authentication
12
 */
13
class Agent extends Configuration implements Authentication
14
{
15
    /**
16
     * Username.
17
     *
18
     * @var string
19
     */
20
    protected $username;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param  object $configuration Configuration object
26
     * @return void
27
     */
28
    public function __construct(Configuration $configuration)
29
    {
30
        $this->username = $configuration->get_username();
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36
    final public function authenticate($resource)
37
    {
38
        if (@ssh2_auth_agent($resource, $this->username) === FALSE)
39
        {
40
            throw new \RuntimeException('Agent based authentication failed.');
41
        }
42
    }
43
}
44