UnknownFrameException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 2
crap 1
1
<?php
2
namespace Hyphper\Frame\Exception;
3
4
/**
5
 * A frame of unknown type was received.
6
 *
7
 * @package Hyphper\Frame
8
 */
9
class UnknownFrameException extends \Exception
10
{
11
    protected $frame_type;
12
    protected $length;
13
14
    /**
15
     * UnknownFrameException constructor.
16
     *
17
     * @param string $frame_type
18
     * @param int $length
19
     */
20 14
    public function __construct($frame_type, $length)
21
    {
22 14
        $this->frame_type = $frame_type;
23 14
        $this->length = $length;
24
25 14
        parent::__construct(
26
            sprintf(
27 14
                "UnknownFrameError: Unknown frame type 0x%X received, length %d bytes",
28
                $frame_type,
29
                $length
30
            )
31
        );
32 14
    }
33
34
    /**
35
     * @return string
36
     */
37 12
    public function getFrameType()
38
    {
39 12
        return $this->frame_type;
40
    }
41
42
    /**
43
     * @return int
44
     */
45 12
    public function getLength()
46
    {
47 12
        return $this->length;
48
    }
49
}
50