MDL-65759 library: Update php-css-parser to 8.3.0
[moodle.git] / lib / php-css-parser / Value / URL.php
1 <?php
3 namespace Sabberworm\CSS\Value;
5 use Sabberworm\CSS\Parsing\ParserState;
7 class URL extends PrimitiveValue {
9         private $oURL;
11         public function __construct(CSSString $oURL, $iLineNo = 0) {
12                 parent::__construct($iLineNo);
13                 $this->oURL = $oURL;
14         }
16         public static function parse(ParserState $oParserState) {
17                 $bUseUrl = $oParserState->comes('url', true);
18                 if ($bUseUrl) {
19                         $oParserState->consume('url');
20                         $oParserState->consumeWhiteSpace();
21                         $oParserState->consume('(');
22                 }
23                 $oParserState->consumeWhiteSpace();
24                 $oResult = new URL(CSSString::parse($oParserState), $oParserState->currentLine());
25                 if ($bUseUrl) {
26                         $oParserState->consumeWhiteSpace();
27                         $oParserState->consume(')');
28                 }
29                 return $oResult;
30         }
33         public function setURL(CSSString $oURL) {
34                 $this->oURL = $oURL;
35         }
37         public function getURL() {
38                 return $this->oURL;
39         }
41         public function __toString() {
42                 return $this->render(new \Sabberworm\CSS\OutputFormat());
43         }
45         public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat) {
46                 return "url({$this->oURL->render($oOutputFormat)})";
47         }
49 }