Completed
Push — master ( a1a7b2...43b437 )
by Robin
02:13
created

PostCommand::getExpectedResponseCodes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
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
 * PostCommand
19
 *
20
 * @author thebandit
21
 */
22
class PostCommand extends Command implements CommandInterface
23
{  
24
   /**
25
    * Constructor.
26
    */
27 8
   public function __construct()
28
    {        
29 8
        parent::__construct(array());
30 8
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 1
    public function execute()
36
    {
37 1
        return 'POST';
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 2
    public function getExpectedResponseCodes()
44
    {
45
        return array(
46 2
            Response::SEND_ARTICLE => 'onSendArticle',
47 2
            Response::POSTING_NOT_PERMITTED => 'onPostingNotPermitted',
48 2
        );
49
    }
50
51 1
    public function onSendArticle(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...
52
    {
53 1
        return;
0 ignored issues
show
Coding Style introduced by
Empty return statement not required here
Loading history...
54
    }
55
56 1
    public function onPostingNotPermitted(Response $response)
57
    {
58 1
        throw new RuntimeException('Posting not permitted.', $response->getStatusCode());
59
    }
60
}
61