Completed
Push — master ( 0a1061...26ca4f )
by Marco
10:28
created

CommentTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setComment() 0 5 1
A getComment() 0 3 1
1
<?php namespace Comodojo\Zip\Traits;
2
3
use \Comodojo\Zip\Interfaces\ZipInterface;
4
5
/**
6
 * Set/get the archive comment.
7
 *
8
 * @package     Comodojo Zip
9
 * @author      Marco Giovinazzi <[email protected]>
10
 * @license     MIT
11
 *
12
 * LICENSE:
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
 * THE SOFTWARE.
21
 */
22
23
trait CommentTrait {
24
25
    /**
26
     * Set the comment for the current archive
27
     *
28
     * @return ZipInterface
29
     */
30
    public function setComment(string $comment): ZipInterface {
31
32
        $this->getArchive()->setArchiveComment($comment);
0 ignored issues
show
Bug introduced by
It seems like getArchive() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $this->/** @scrutinizer ignore-call */ 
33
               getArchive()->setArchiveComment($comment);
Loading history...
33
34
        return $this;
35
36
    }
37
38
    /**
39
     * Get the current zip archive comment
40
     *
41
     * @return string
42
     */
43
    public function getComment(): ?string {
44
45
        return $this->getArchive()->getArchiveComment();
46
47
    }
48
49
}
50