CommentTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 24
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setComment() 0 4 1
A getComment() 0 3 1
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