Search moodle.org's
Developer Documentation

See Release Notes

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

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

   1  <?php
   2  
   3  namespace Sabberworm\CSS\RuleSet;
   4  
   5  use Sabberworm\CSS\OutputFormat;
   6  use Sabberworm\CSS\Property\AtRule;
   7  
   8  /**
   9   * A RuleSet constructed by an unknown at-rule. `@font-face` rules are rendered into AtRuleSet objects.
  10   */
  11  class AtRuleSet extends RuleSet 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 = "@{$this->sType}$sArgs{$oOutputFormat->spaceBeforeOpeningBrace()}{";
  69          $sResult .= parent::render($oOutputFormat);
  70          $sResult .= '}';
  71          return $sResult;
  72      }
  73  }