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.
   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  }