Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are 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  }