Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.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  }