Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace Sabberworm\CSS\Property;
4
 
5
use Sabberworm\CSS\Comment\Comment;
6
use Sabberworm\CSS\OutputFormat;
7
 
8
/**
9
 * `CSSNamespace` represents an `@namespace` rule.
10
 */
11
class CSSNamespace implements AtRule
12
{
13
    /**
14
     * @var string
15
     */
16
    private $mUrl;
17
 
18
    /**
19
     * @var string
20
     */
21
    private $sPrefix;
22
 
23
    /**
24
     * @var int
25
     */
26
    private $iLineNo;
27
 
28
    /**
29
     * @var array<array-key, Comment>
30
     */
31
    protected $aComments;
32
 
33
    /**
34
     * @param string $mUrl
35
     * @param string|null $sPrefix
36
     * @param int $iLineNo
37
     */
38
    public function __construct($mUrl, $sPrefix = null, $iLineNo = 0)
39
    {
40
        $this->mUrl = $mUrl;
41
        $this->sPrefix = $sPrefix;
42
        $this->iLineNo = $iLineNo;
43
        $this->aComments = [];
44
    }
45
 
46
    /**
47
     * @return int
48
     */
49
    public function getLineNo()
50
    {
51
        return $this->iLineNo;
52
    }
53
 
54
    /**
55
     * @return string
56
     */
57
    public function __toString()
58
    {
59
        return $this->render(new OutputFormat());
60
    }
61
 
62
    /**
63
     * @return string
64
     */
65
    public function render(OutputFormat $oOutputFormat)
66
    {
67
        return '@namespace ' . ($this->sPrefix === null ? '' : $this->sPrefix . ' ')
68
            . $this->mUrl->render($oOutputFormat) . ';';
69
    }
70
 
71
    /**
72
     * @return string
73
     */
74
    public function getUrl()
75
    {
76
        return $this->mUrl;
77
    }
78
 
79
    /**
80
     * @return string|null
81
     */
82
    public function getPrefix()
83
    {
84
        return $this->sPrefix;
85
    }
86
 
87
    /**
88
     * @param string $mUrl
89
     *
90
     * @return void
91
     */
92
    public function setUrl($mUrl)
93
    {
94
        $this->mUrl = $mUrl;
95
    }
96
 
97
    /**
98
     * @param string $sPrefix
99
     *
100
     * @return void
101
     */
102
    public function setPrefix($sPrefix)
103
    {
104
        $this->sPrefix = $sPrefix;
105
    }
106
 
107
    /**
108
     * @return string
109
     */
110
    public function atRuleName()
111
    {
112
        return 'namespace';
113
    }
114
 
115
    /**
116
     * @return array<int, string>
117
     */
118
    public function atRuleArgs()
119
    {
120
        $aResult = [$this->mUrl];
121
        if ($this->sPrefix) {
122
            array_unshift($aResult, $this->sPrefix);
123
        }
124
        return $aResult;
125
    }
126
 
127
    /**
128
     * @param array<array-key, Comment> $aComments
129
     *
130
     * @return void
131
     */
132
    public function addComments(array $aComments)
133
    {
134
        $this->aComments = array_merge($this->aComments, $aComments);
135
    }
136
 
137
    /**
138
     * @return array<array-key, Comment>
139
     */
140
    public function getComments()
141
    {
142
        return $this->aComments;
143
    }
144
 
145
    /**
146
     * @param array<array-key, Comment> $aComments
147
     *
148
     * @return void
149
     */
150
    public function setComments(array $aComments)
151
    {
152
        $this->aComments = $aComments;
153
    }
154
}