AMQPProtocolException::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 17
loc 17
ccs 12
cts 12
cp 1
rs 9.4285
cc 2
eloc 11
nc 2
nop 3
crap 2
1
<?php
2
namespace PhpAmqpLib\Exception;
3
4
//TODO refactor usage of static methods
5
use PhpAmqpLib\Channel\AbstractChannel;
6
use PhpAmqpLib\Helper\MiscHelper;
7
8 View Code Duplication
class AMQPProtocolException extends \Exception implements AMQPExceptionInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /** @var string */
11
    public $amqp_reply_code;
12
13
    /** @var int */
14
    public $amqp_reply_text;
15
16
    /** @var \Exception */
17
    public $amqp_method_sig;
18
19
    /** @var array */
20
    public $args;
21
22
    /**
23
     * @param string $reply_code
24
     * @param int $reply_text
25
     * @param \Exception $method_sig
26
     */
27 5
    public function __construct($reply_code, $reply_text, $method_sig)
28
    {
29 5
        parent::__construct($reply_text, $reply_code);
30
31 5
        $this->amqp_reply_code = $reply_code; // redundant, but kept for BC
32 5
        $this->amqp_reply_text = $reply_text; // redundant, but kept for BC
33 5
        $this->amqp_method_sig = $method_sig;
34
35 5
        $ms = MiscHelper::methodSig($method_sig);
36
37 5
        $PROTOCOL_CONSTANTS_CLASS = AbstractChannel::$PROTOCOL_CONSTANTS_CLASS;
38 5
        $mn = isset($PROTOCOL_CONSTANTS_CLASS::$GLOBAL_METHOD_NAMES[$ms])
39 5
            ? $PROTOCOL_CONSTANTS_CLASS::$GLOBAL_METHOD_NAMES[$ms]
40 5
            : $mn = '';
41
42 5
        $this->args = array($reply_code, $reply_text, $method_sig, $mn);
43 5
    }
44
}
45