Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Crc32Exception.php « Exception « PhpZip « src « zip « nelexa « vendor - github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f82b2335bae4dfb28ed3042bccace1b18923479d (plain)
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
<?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($name . " (expected CRC32 value 0x" .
            dechex($expected) . ", but is actually 0x" . dechex($actual) . ")");
        assert($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;
    }
}