Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

   1  <?php
   2  
   3  namespace Sabberworm\CSS\CSSList;
   4  
   5  use Sabberworm\CSS\OutputFormat;
   6  use Sabberworm\CSS\Property\AtRule;
   7  
   8  /**
   9   * A `BlockList` constructed by an unknown at-rule. `@media` rules are rendered into `AtRuleBlockList` objects.
  10   */
  11  class AtRuleBlockList extends CSSBlockList 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 = $oOutputFormat->sBeforeAtRuleBlock;
  69          $sResult .= "@{$this->sType}$sArgs{$oOutputFormat->spaceBeforeOpeningBrace()}{";
  70          $sResult .= parent::render($oOutputFormat);
  71          $sResult .= '}';
  72          $sResult .= $oOutputFormat->sAfterAtRuleBlock;
  73          return $sResult;
  74      }
  75  
  76      /**
  77       * @return bool
  78       */
  79      public function isRootList()
  80      {
  81          return false;
  82      }
  83  }