Completed
Push — master ( 67a981...19aadf )
by Robin
04:39 queued 02:52
created

AuthInfoCommand::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the NNTP library.
5
 *
6
 * (c) Robin van der Vleuten <[email protected]>
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 Rvdv\Nntp\Command;
13
14
use Rvdv\Nntp\Exception\RuntimeException;
15
use Rvdv\Nntp\Response\Response;
16
17
/**
18
 * AuthInfoCommand.
19
 *
20
 * @author Robin van der Vleuten <[email protected]>
21
 */
22
class AuthInfoCommand extends Command implements CommandInterface
23
{
24
    const AUTHINFO_USER = 'USER';
25
    const AUTHINFO_PASS = 'PASS';
26
27
    /**
28
     * @var string
29
     */
30
    private $type;
31
32
    /**
33
     * @var string
34
     */
35
    private $value;
36
37 12
    public function __construct($type, $value)
38
    {
39 12
        $this->type = $type;
40 12
        $this->value = $value;
41
42 12
        parent::__construct();
43 12
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 1
    public function __invoke()
49
    {
50 1
        return sprintf('AUTHINFO %s %s', $this->type, $this->value);
51
    }
52
53 1
    public function onAuthenticationAccepted(Response $response)
54
    {
55 1
        return $response;
56
    }
57
58 1
    public function onPasswordRequired(Response $response)
59
    {
60 1
        return $response;
61
    }
62
63 1
    public function onAuthenticationRejected(Response $response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
    {
65 1
        throw new RuntimeException(sprintf('Authentication failed with given value for type %s', $this->type));
66
    }
67
68 1
    public function onAuthenticationOutOfSequence(Response $response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
69
    {
70 1
        throw new RuntimeException(sprintf('Authentication is out of sequence for type %s', $this->type));
71
    }
72
}
73