Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
Comment
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
5 / 5
8
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setComment
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getComment
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 render
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
4
 __toString
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-2023 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 * Pop CSS comment class
18 *
19 * @category   Pop
20 * @package    Pop\Css
21 * @author     Nick Sagona, III <dev@nolainteractive.com>
22 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
23 * @license    http://www.popphp.org/license     New BSD License
24 * @version    1.1.0
25 */
26class Comment
27{
28
29    /**
30     * Comment string
31     * @var string
32     */
33    protected $comment = null;
34
35    /**
36     * Constructor
37     *
38     * Instantiate the CSS comment object
39     *
40     * @param string $comment
41     */
42    public function __construct($comment)
43    {
44        $this->setComment($comment);
45    }
46
47    /**
48     * Set comment
49     *
50     * @param  string $comment
51     * @return self
52     */
53    public function setComment($comment)
54    {
55        $this->comment = $comment;
56        return $this;
57    }
58
59    /**
60     * Get comment
61     *
62     * @return string
63     */
64    public function getComment()
65    {
66        return $this->comment;
67    }
68
69    /**
70     * Method to render the selector CSS
71     *
72     * @return string
73     */
74    public function render()
75    {
76        $comment = '/**' . PHP_EOL;
77
78        if (strpos($this->comment, PHP_EOL) !== false) {
79            $commentAry = explode(PHP_EOL, $this->comment);
80        } else {
81            $commentAry = (strlen($this->comment) > 80) ?
82                explode(PHP_EOL, wordwrap($this->comment, 80, PHP_EOL)) : [$this->comment];
83        }
84
85        foreach ($commentAry as $line) {
86            $comment .= ' * ' . $line . PHP_EOL;
87        }
88
89        $comment .= ' */' . PHP_EOL;
90
91        return $comment;
92    }
93
94    /**
95     * To string method
96     *
97     * @return string
98     */
99    public function __toString()
100    {
101        return $this->render();
102    }
103
104}