Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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  }