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

XpathCommand::__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\Response\Response;
15
16
class XpathCommand extends Command implements CommandInterface
17
{
18
    /**
19
     * @var int
20
     */
21
    const FOUND_PATH = 223;
22
23
    /**
24
     * @var int
25
     */
26
    const INVALID_REFERENCE = 501;
27
28
    /**
29
     * @var string
30
     */
31
    private $reference;
32
33
    /**
34
     * Constructor.
35
     *
36
     * @param string $reference The reference
37
     */
38 3
    public function __construct($reference)
39
    {
40 3
        $this->reference = $reference;
41
42 3
        parent::__construct();
43 3
    }
44
45
    /**
46
     * @return string
47
     */
48 1
    public function __invoke()
49
    {
50 1
        return sprintf('XPATH %s', $this->reference);
51
    }
52
53
    /**
54
     * Return the message's reference.
55
     *
56
     * @param Response $response
57
     */
58 1
    public function onFoundPath(Response $response)
59
    {
60 1
        return $response->getMessage();
61
    }
62
63
    /**
64
     * If we didn't find the message, just return an empty response.
65
     *
66
     * @param Response $response
67
     */
68 1
    public function onInvalidMessage(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
        return null;
71
    }
72
}
73