GroupCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 40
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __invoke() 0 4 1
A onGroupSelected() 0 4 1
A onNoSuchGroup() 0 4 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
 * GroupCommand.
19
 *
20
 * @author Robin van der Vleuten <[email protected]>
21
 */
22
class GroupCommand extends Command implements CommandInterface
23
{
24
    /**
25
     * @var string
26
     */
27
    private $group;
28
29
    /**
30
     * Constructor.
31
     *
32
     * @param string $group the name of the group
33
     */
34 6
    public function __construct($group)
35
    {
36 6
        $this->group = $group;
37
38 6
        parent::__construct();
39 6
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 1
    public function __invoke()
45
    {
46 1
        return sprintf('GROUP %s', $this->group);
47
    }
48
49
    /**
50
     * @return array
51
     */
52 1
    public function onGroupSelected(Response $response)
53
    {
54 1
        return array_combine(['count', 'first', 'last', 'name'], explode(' ', $response->getMessage()));
55
    }
56
57 1
    public function onNoSuchGroup(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...
58
    {
59 1
        throw new RuntimeException(sprintf('A group with name %s does not exists on server', $this->group));
60
    }
61
}
62