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