diff --git a/README.md b/README.md index 9df03fa..4c19616 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,7 @@ [![WezomAgency](https://img.shields.io/badge/composer-require-orange.svg)](https://packagist.org/packages/wezom-agency/r2d2) [![WezomAgency](https://img.shields.io/badge/Wezom-Agency-red.svg)](https://github.com/WezomAgency) -> R2D2 tiny helper - - +> tiny helper --- @@ -35,7 +33,8 @@ WezomAgency\R2D2::eject()->set('KEY', VALUE); ### API -[See docs sections ►](https://github.com/WezomAgency/r2d2/blob/master/docs/index.md) +_Working in progress..._ +[See draft docs sections ►](https://github.com/WezomAgency/r2d2/blob/master/docs/index.md) --- diff --git a/src/WezomAgency/R2D2.php b/src/WezomAgency/R2D2.php index f8cd4af..569dc42 100644 --- a/src/WezomAgency/R2D2.php +++ b/src/WezomAgency/R2D2.php @@ -75,12 +75,12 @@ public function attr($name, $value) } if (is_array($value) && $name === 'style') { - $css = $this->cssRules($value); + $css = $this->cssRules(array_filter($value)); return $css ? 'style="' . $css . '"' : ''; } if (is_array($value) && $name === 'class') { - return 'class="' . implode(' ', $value) . '"'; + return 'class="' . implode(' ', array_filter($value)) . '"'; } if (strpos($name, 'json-data-') === 0) { @@ -101,14 +101,14 @@ public function attr($name, $value) */ public function attrs($attrs) { - $markup = []; + $list = []; foreach ($attrs as $name => $value) { - $element = $this->attr($name, $value); - if (!is_null($element)) { - $markup[] = $element; + $attr = $this->attr($name, $value); + if (!is_null($attr)) { + $list[] = $attr; } } - return count($markup) > 0 ? ' ' . implode(' ', $markup) : ''; + return count($list) > 0 ? ' ' . implode(' ', $list) : ''; }