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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body