Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php namespace RedeyeVentures\GeoPattern\SVGElements;
   2  
   3  abstract class Base
   4  {
   5      protected $tag;
   6      protected $elements;
   7      protected $args;
   8  
   9      function __construct($args)
  10      {
  11          $this->args = $args;
  12      }
  13  
  14      public function elementsToString()
  15      {
  16          $string = ' ';
  17          foreach ($this->elements as $key => $value)
  18          {
  19              $string .= "$key=\"$value\" ";
  20          }
  21          return $string;
  22      }
  23  
  24      public function argsToString()
  25      {
  26          $string = '';
  27          foreach ($this->args as $key => $value)
  28          {
  29              if (is_array($value))
  30              {
  31                  $string .= "$key=\"";
  32                  foreach ($value as $k => $v)
  33                  {
  34                      $string .= "$k:$v;";
  35                  }
  36                  $string .= '" ';
  37              }
  38              else
  39              {
  40                  $string .= "$key=\"$value\" ";
  41              }
  42          }
  43          return $string;
  44      }
  45  
  46      public function getString()
  47      {
  48          return "<{$this->tag}{$this->elementsToString()}{$this->argsToString()}/>";
  49      }
  50  
  51      function __toString()
  52      {
  53          return $this->getString();
  54      }
  55  }