UnexpectedHeaderException::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace CHMLib\Exception;
4
5
/**
6
 * Exception thrown when finding an unexpected header.
7
 */
8
class UnexpectedHeaderException extends Exception
9
{
10
    /**
11
     * The expected header identifier.
12
     *
13
     * @var string
14
     */
15
    protected $expectedHeader;
16
17
    /**
18
     * The found header identifier.
19
     *
20
     * @var string
21
     */
22
    protected $foundHeader;
23
24
    /**
25
     * Create a new instance.
26
     *
27
     * @param string $expectedHeader The expected header identifier.
28
     * @param string $foundHeader The found header identifier.
29
     */
30
    public static function create($expectedHeader, $foundHeader)
31
    {
32
        $result = new static("Invalid header identifier: expecting '$expectedHeader', found '$foundHeader'");
33
        $result->expectedHeader = $expectedHeader;
34
        $result->foundHeader = $foundHeader;
35
36
        return $result;
37
    }
38
39
    /**
40
     * Get the expected header identifier.
41
     *
42
     * @return string
43
     */
44
    public function getExpectedHeader()
45
    {
46
        return $this->expectedHeader;
47
    }
48
49
    /**
50
     * Get the found header identifier.
51
     *
52
     * @return string
53
     */
54
    public function getFoundHeader()
55
    {
56
        return $this->foundHeader;
57
    }
58
}
59