CommentTrait::getComment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Comodojo\Zip\Traits;
4
5
use \Comodojo\Zip\Interfaces\ZipInterface;
6
use \ZipArchive;
7
8
/**
9
 * Set/get the archive comment.
10
 *
11
 * @package     Comodojo Zip
12
 * @author      Marco Giovinazzi <[email protected]>
13
 * @license     MIT
14
 *
15
 * LICENSE:
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
 * THE SOFTWARE.
24
 */
25
26
trait CommentTrait
27
{
28
29
    abstract public function getArchive(): ?ZipArchive;
30
31
    /**
32
     * Set the comment for the current archive
33
     *
34
     * @return ZipInterface
35
     */
36 1
    public function setComment(string $comment): ZipInterface
37
    {
38 1
        $this->getArchive()->setArchiveComment($comment);
39 1
        return $this;
40
    }
41
42
    /**
43
     * Get the current zip archive comment
44
     *
45
     * @return string
46
     */
47 2
    public function getComment(): ?string
48
    {
49 2
        return $this->getArchive()->getArchiveComment();
50
    }
51
}
52