Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
CommentTrait
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 addComment
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 getComments
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasComments
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@nolainteractive.com>
7 * @copyright  Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Css;
15
16/**
17 * CSS comment trait
18 *
19 * @category   Pop
20 * @package    Pop\Css
21 * @author     Nick Sagona, III <dev@nolainteractive.com>
22 * @copyright  Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)
23 * @license    http://www.popphp.org/license     New BSD License
24 * @version    2.0.0
25 */
26trait CommentTrait
27{
28
29    /**
30     * Comments
31     * @var array
32     */
33    protected array $comments = [];
34
35    /**
36     * Add CSS comment
37     *
38     * @param  Comment|string $comment
39     * @param  int            $wrap
40     * @param  bool           $trailingNewLine
41     * @return static
42     */
43    public function addComment(Comment|string $comment, int $wrap = 80, bool $trailingNewLine = false): static
44    {
45        if (is_string($comment)) {
46            $comment = new Comment($comment, $wrap, $trailingNewLine);
47        }
48        $this->comments[] = $comment;
49        return $this;
50    }
51
52    /**
53     * Get CSS comments
54     *
55     * @return array
56     */
57    public function getComments(): array
58    {
59        return $this->comments;
60    }
61
62    /**
63     * Has CSS comments
64     *
65     * @return bool
66     */
67    public function hasComments(): bool
68    {
69        return !empty($this->comments);
70    }
71
72}