Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
namespace Sabberworm\CSS\RuleSet;
4
 
5
use Sabberworm\CSS\OutputFormat;
6
use Sabberworm\CSS\Property\AtRule;
7
 
8
/**
9
 * This class represents rule sets for generic at-rules which are not covered by specific classes, i.e., not
10
 * `@import`, `@charset` or `@media`.
11
 *
12
 * A common example for this is `@font-face`.
13
 */
14
class AtRuleSet extends RuleSet implements AtRule
15
{
16
    /**
17
     * @var string
18
     */
19
    private $sType;
20
 
21
    /**
22
     * @var string
23
     */
24
    private $sArgs;
25
 
26
    /**
27
     * @param string $sType
28
     * @param string $sArgs
29
     * @param int $iLineNo
30
     */
31
    public function __construct($sType, $sArgs = '', $iLineNo = 0)
32
    {
33
        parent::__construct($iLineNo);
34
        $this->sType = $sType;
35
        $this->sArgs = $sArgs;
36
    }
37
 
38
    /**
39
     * @return string
40
     */
41
    public function atRuleName()
42
    {
43
        return $this->sType;
44
    }
45
 
46
    /**
47
     * @return string
48
     */
49
    public function atRuleArgs()
50
    {
51
        return $this->sArgs;
52
    }
53
 
54
    /**
55
     * @return string
56
     */
57
    public function __toString()
58
    {
59
        return $this->render(new OutputFormat());
60
    }
61
 
62
    /**
63
     * @param OutputFormat|null $oOutputFormat
64
     *
65
     * @return string
66
     */
67
    public function render($oOutputFormat)
68
    {
69
        $sResult = $oOutputFormat->comments($this);
70
        $sArgs = $this->sArgs;
71
        if ($sArgs) {
72
            $sArgs = ' ' . $sArgs;
73
        }
74
        $sResult .= "@{$this->sType}$sArgs{$oOutputFormat->spaceBeforeOpeningBrace()}{";
75
        $sResult .= $this->renderRules($oOutputFormat);
76
        $sResult .= '}';
77
        return $sResult;
78
    }
79
}