You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
2 years ago
|
<?php namespace RedeyeVentures\GeoPattern\SVGElements;
|
||
|
|
||
|
abstract class Base
|
||
|
{
|
||
|
protected $tag;
|
||
|
protected $elements;
|
||
|
protected $args;
|
||
|
|
||
|
function __construct($args)
|
||
|
{
|
||
|
$this->args = $args;
|
||
|
}
|
||
|
|
||
|
public function elementsToString()
|
||
|
{
|
||
|
$string = ' ';
|
||
|
foreach ($this->elements as $key => $value)
|
||
|
{
|
||
|
$string .= "$key=\"$value\" ";
|
||
|
}
|
||
|
return $string;
|
||
|
}
|
||
|
|
||
|
public function argsToString()
|
||
|
{
|
||
|
$string = '';
|
||
|
foreach ($this->args as $key => $value)
|
||
|
{
|
||
|
if (is_array($value))
|
||
|
{
|
||
|
$string .= "$key=\"";
|
||
|
foreach ($value as $k => $v)
|
||
|
{
|
||
|
$string .= "$k:$v;";
|
||
|
}
|
||
|
$string .= '" ';
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$string .= "$key=\"$value\" ";
|
||
|
}
|
||
|
}
|
||
|
return $string;
|
||
|
}
|
||
|
|
||
|
public function getString()
|
||
|
{
|
||
|
return "<{$this->tag}{$this->elementsToString()}{$this->argsToString()}/>";
|
||
|
}
|
||
|
|
||
|
function __toString()
|
||
|
{
|
||
|
return $this->getString();
|
||
|
}
|
||
|
}
|