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\RuleSet;
4
 
5
use Sabberworm\CSS\OutputFormat;
6
use Sabberworm\CSS\Property\AtRule;
7
 
8
/**
9
 * A RuleSet constructed by an unknown at-rule. `@font-face` rules are rendered into AtRuleSet objects.
10
 */
11
class AtRuleSet extends RuleSet implements AtRule
12
{
13
    /**
14
     * @var string
15
     */
16
    private $sType;
17
 
18
    /**
19
     * @var string
20
     */
21
    private $sArgs;
22
 
23
    /**
24
     * @param string $sType
25
     * @param string $sArgs
26
     * @param int $iLineNo
27
     */
28
    public function __construct($sType, $sArgs = '', $iLineNo = 0)
29
    {
30
        parent::__construct($iLineNo);
31
        $this->sType = $sType;
32
        $this->sArgs = $sArgs;
33
    }
34
 
35
    /**
36
     * @return string
37
     */
38
    public function atRuleName()
39
    {
40
        return $this->sType;
41
    }
42
 
43
    /**
44
     * @return string
45
     */
46
    public function atRuleArgs()
47
    {
48
        return $this->sArgs;
49
    }
50
 
51
    /**
52
     * @return string
53
     */
54
    public function __toString()
55
    {
56
        return $this->render(new OutputFormat());
57
    }
58
 
59
    /**
60
     * @return string
61
     */
62
    public function render(OutputFormat $oOutputFormat)
63
    {
64
        $sArgs = $this->sArgs;
65
        if ($sArgs) {
66
            $sArgs = ' ' . $sArgs;
67
        }
68
        $sResult = "@{$this->sType}$sArgs{$oOutputFormat->spaceBeforeOpeningBrace()}{";
69
        $sResult .= parent::render($oOutputFormat);
70
        $sResult .= '}';
71
        return $sResult;
72
    }
73
}