Passed
Push — master ( ca068f...f2d295 )
by Alexey
03:12 queued 16s
created

EndOfCentralDirectory::setComment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace PhpZip\Model;
4
5
/**
6
 * End of Central Directory.
7
 *
8
 * @author Ne-Lexa [email protected]
9
 * @license MIT
10
 */
11
class EndOfCentralDirectory
12
{
13
    /** Zip64 End Of Central Directory Record. */
14
    const ZIP64_END_OF_CD_RECORD_SIG = 0x06064B50;
15
16
    /** Zip64 End Of Central Directory Locator. */
17
    const ZIP64_END_OF_CD_LOCATOR_SIG = 0x07064B50;
18
19
    /** End Of Central Directory Record signature. */
20
    const END_OF_CD_SIG = 0x06054B50;
21
22
    /**
23
     * The minimum length of the End Of Central Directory Record.
24
     *
25
     * end of central dir signature    4
26
     * number of this disk             2
27
     * number of the disk with the
28
     * start of the central directory  2
29
     * total number of entries in the
30
     * central directory on this disk  2
31
     * total number of entries in
32
     * the central directory           2
33
     * size of the central directory   4
34
     * offset of start of central      *
35
     * directory with respect to       *
36
     * the starting disk number        4
37
     * zipfile comment length          2
38
     */
39
    const END_OF_CENTRAL_DIRECTORY_RECORD_MIN_LEN = 22;
40
41
    /**
42
     * The length of the Zip64 End Of Central Directory Locator.
43
     * zip64 end of central dir locator
44
     * signature                       4
45
     * number of the disk with the
46
     * start of the zip64 end of
47
     * central directory               4
48
     * relative offset of the zip64
49
     * end of central directory record 8
50
     * total number of disks           4.
51
     */
52
    const ZIP64_END_OF_CD_LOCATOR_LEN = 20;
53
54
    /**
55
     * The minimum length of the Zip64 End Of Central Directory Record.
56
     *
57
     * zip64 end of central dir
58
     * signature                        4
59
     * size of zip64 end of central
60
     * directory record                 8
61
     * version made by                  2
62
     * version needed to extract        2
63
     * number of this disk              4
64
     * number of the disk with the
65
     * start of the central directory   4
66
     * total number of entries in the
67
     * central directory on this disk   8
68
     * total number of entries in
69
     * the central directory            8
70
     * size of the central directory    8
71
     * offset of start of central
72
     * directory with respect to
73
     * the starting disk number         8
74
     */
75
    const ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_MIN_LEN = 56;
76
77
    /** @var int Count files. */
78
    private $entryCount;
79
80
    /** @var int Central Directory Offset. */
81
    private $cdOffset;
82
83
    /** @var int */
84
    private $cdSize;
85
86
    /** @var string|null The archive comment. */
87
    private $comment;
88
89
    /** @var bool Zip64 extension */
90
    private $zip64;
91
92
    /**
93
     * EndOfCentralDirectory constructor.
94
     *
95
     * @param int        $entryCount
96
     * @param int        $cdOffset
97
     * @param int        $cdSize
98
     * @param bool       $zip64
99
     * @param mixed|null $comment
100
     */
101
    public function __construct($entryCount, $cdOffset, $cdSize, $zip64, $comment = null)
102
    {
103
        $this->entryCount = $entryCount;
104
        $this->cdOffset = $cdOffset;
105
        $this->cdSize = $cdSize;
106
        $this->zip64 = $zip64;
107
        $this->comment = $comment;
108
    }
109
110
    /**
111
     * @param string|null $comment
112
     */
113
    public function setComment($comment)
114
    {
115
        $this->comment = $comment;
116
    }
117
118
    /**
119
     * @return int
120
     */
121
    public function getEntryCount()
122
    {
123
        return $this->entryCount;
124
    }
125
126
    /**
127
     * @return int
128
     */
129
    public function getCdOffset()
130
    {
131
        return $this->cdOffset;
132
    }
133
134
    /**
135
     * @return int
136
     */
137
    public function getCdSize()
138
    {
139
        return $this->cdSize;
140
    }
141
142
    /**
143
     * @return string|null
144
     */
145
    public function getComment()
146
    {
147
        return $this->comment;
148
    }
149
150
    /**
151
     * @return bool
152
     */
153
    public function isZip64()
154
    {
155
        return $this->zip64;
156
    }
157
}
158