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\Value;
   4  
   5  use Sabberworm\CSS\OutputFormat;
   6  
   7  class CSSFunction extends ValueList
   8  {
   9      /**
  10       * @var string
  11       */
  12      protected $sName;
  13  
  14      /**
  15       * @param string $sName
  16       * @param RuleValueList|array<int, RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string> $aArguments
  17       * @param string $sSeparator
  18       * @param int $iLineNo
  19       */
  20      public function __construct($sName, $aArguments, $sSeparator = ',', $iLineNo = 0)
  21      {
  22          if ($aArguments instanceof RuleValueList) {
  23              $sSeparator = $aArguments->getListSeparator();
  24              $aArguments = $aArguments->getListComponents();
  25          }
  26          $this->sName = $sName;
  27          $this->iLineNo = $iLineNo;
  28          parent::__construct($aArguments, $sSeparator, $iLineNo);
  29      }
  30  
  31      /**
  32       * @return string
  33       */
  34      public function getName()
  35      {
  36          return $this->sName;
  37      }
  38  
  39      /**
  40       * @param string $sName
  41       *
  42       * @return void
  43       */
  44      public function setName($sName)
  45      {
  46          $this->sName = $sName;
  47      }
  48  
  49      /**
  50       * @return array<int, RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string>
  51       */
  52      public function getArguments()
  53      {
  54          return $this->aComponents;
  55      }
  56  
  57      /**
  58       * @return string
  59       */
  60      public function __toString()
  61      {
  62          return $this->render(new OutputFormat());
  63      }
  64  
  65      /**
  66       * @return string
  67       */
  68      public function render(OutputFormat $oOutputFormat)
  69      {
  70          $aArguments = parent::render($oOutputFormat);
  71          return "{$this->sName}({$aArguments})";
  72      }
  73  }