attr[$method] = $parameters[0] ?? NULL; return $this; } /** * Magic Constructor */ public function __construct() { $this->html = Singleton::class('ZN\Hypertext\Html'); } /** * Sets attributes * * @param array $attributes * * @return Table */ public function attr(array $attributes) : Table { foreach( $attributes as $att => $val ) { $this->attr[$att] = $val; } return $this; } /** * Sets table cell * * @param int $spacing * @param int $padding * * @return Table */ public function cell(int $spacing, int $padding) : Table { $this->attr['cellspacing'] = $spacing; $this->attr['cellpadding'] = $padding; return $this; } /** * Sets table border * * @param int $border * @param string $color = NULL * * @return Table */ public function border(int $border, ?string $color = NULL) : Table { $this->attr['border'] = $border; if( ! empty($color) ) { $this->attr['bordercolor'] = $color; } return $this; } /** * Sets table size * * @param int $width * @param int $height * * @return Table */ public function size(int $width, int $height) : Table { $this->attr['width'] = $width; $this->attr['height'] = $height; return $this; } /** * Sets table style attribute * * @param array $attributes * * @return Table */ public function style(array $attributes) : Table { $attribute = ''; foreach( $attributes as $key => $values ) { if( is_numeric($key) ) { $key = $values; } $attribute .= ' '.$key.':'.$values.';'; } $this->attr['style'] = $attribute; return $this; } /** * Creates table * * @param string ...$elements * * @return string */ public function create(...$elements) : string { $table = '