Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

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

   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  }