Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   1  <?php
   2  
   3  namespace Sabberworm\CSS\Value;
   4  
   5  use Sabberworm\CSS\Parsing\ParserState;
   6  
   7  class URL extends PrimitiveValue {
   8  
   9  	 private $oURL;
  10  
  11  	public function __construct(CSSString $oURL, $iLineNo = 0) {
  12  	 	 parent::__construct($iLineNo);
  13  	 	 $this->oURL = $oURL;
  14  	 }
  15  
  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  	 }
  31  
  32  
  33  	public function setURL(CSSString $oURL) {
  34  	 	 $this->oURL = $oURL;
  35  	 }
  36  
  37  	public function getURL() {
  38  	 	 return $this->oURL;
  39  	 }
  40  
  41  	public function __toString() {
  42  	 	 return $this->render(new \Sabberworm\CSS\OutputFormat());
  43  	 }
  44  
  45  	public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat) {
  46  	 	 return "url({$this->oURL->render($oOutputFormat)})";
  47  	 }
  48  
  49  }