Crc32Exception   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 54.55%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 55
ccs 6
cts 11
cp 0.5455
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getActualCrc() 0 3 1
A __construct() 0 12 1
A getExpectedCrc() 0 3 1
1
<?php
2
3
namespace PhpZip\Exception;
4
5
/**
6
 * Thrown to indicate a CRC32 mismatch between the declared value in the
7
 * Central File Header and the Data Descriptor or between the declared value
8
 * and the computed value from the decompressed data.
9
 *
10
 * The exception detail message is the name of the ZIP entry.
11
 *
12
 * @author Ne-Lexa [email protected]
13
 * @license MIT
14
 */
15
class Crc32Exception extends ZipException
16
{
17
    /**
18
     * Expected crc.
19
     *
20
     * @var int
21
     */
22
    private $expectedCrc;
23
24
    /**
25
     * Actual crc.
26
     *
27
     * @var int
28
     */
29
    private $actualCrc;
30
31
    /**
32
     * Crc32Exception constructor.
33
     *
34
     * @param string $name
35
     * @param int    $expected
36
     * @param int    $actual
37
     */
38 2
    public function __construct($name, $expected, $actual)
39
    {
40 2
        parent::__construct(
41
            sprintf(
42 2
                '%s (expected CRC32 value 0x%x, but is actually 0x%x)',
43
                $name,
44
                $expected,
45
                $actual
46
            )
47
        );
48 2
        $this->expectedCrc = $expected;
49 2
        $this->actualCrc = $actual;
50 2
    }
51
52
    /**
53
     * Returns expected crc.
54
     *
55
     * @return int
56
     */
57
    public function getExpectedCrc()
58
    {
59
        return $this->expectedCrc;
60
    }
61
62
    /**
63
     * Returns actual crc.
64
     *
65
     * @return int
66
     */
67
    public function getActualCrc()
68
    {
69
        return $this->actualCrc;
70
    }
71
}
72