CssSelectors::geCssSelector()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 4
nop 3
dl 0
loc 16
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files\Assets\Css;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
/**
15
 * modulebuilder module.
16
 *
17
 * @copyright       XOOPS Project (https://xoops.org)
18
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
19
 *
20
 * @since           2.5.0
21
 *
22
 * @author          Txmod Xoops https://xoops.org 
23
 *                  Goffy https://myxoops.org
24
 *
25
 */
26
27
/**
28
 * Class CssSelectors.
29
 */
30
class CssSelectors
31
{
32
    /**
33
     * @static function getInstance
34
     * @param null
35
     *
36
     * @return CssSelectors
37
     */
38
    public static function getInstance()
39
    {
40
        static $instance = false;
41
        if (!$instance) {
42
            $instance = new self();
43
        }
44
45
        return $instance;
46
    }
47
48
    /**
49
     * @public function geCssComment
50
     * @param string $comment
51
     * @param string $t
52
     * @return string
53
     */
54
    public function geCssComment($comment, $t)
55
    {
56
        $ret = ('' != $comment) ? "{$t}/* {$comment} */" : '';
57
58
        return $ret;
59
    }
60
61
    /**
62
     * @public function geCssSelector
63
     * @param string $selector
64
     * @param mixed  $content
65
     * @param string $t
66
     * @return string
67
     */
68
    public function geCssSelector($selector, $content, $t)
69
    {
70
        $ret = '';
71
        if (\is_array($selector)) {
0 ignored issues
show
introduced by
The condition is_array($selector) is always false.
Loading history...
72
            $ret .= $t . \implode("\n", $selector) . ' {';
73
        } else {
74
            $ret .= $selector . ' {';
75
        }
76
        if (\is_array($content)) {
77
            $ret .= $t . \implode("\n", $content) . ';';
78
        } else {
79
            $ret .= $content . ';';
80
        }
81
        $ret .= '}';
82
83
        return $ret;
84
    }
85
}
86