From 544e48fefe1e052d81994c2abb49b8fe8b035040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=83=D1=82=D1=87=D0=B5=D0=BD=D0=BA=D0=BE=20=D0=9E?= =?UTF-8?q?=D0=BB=D0=B5=D0=B3?= Date: Tue, 21 Jan 2020 11:28:26 +0200 Subject: [PATCH] 1.8.0 --- README.md | 7 +++---- src/WezomAgency/R2D2.php | 14 +++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) 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) : ''; }