Skip to content

Commit

Permalink
Merge pull request #33 from dutchenkoOleg/master
Browse files Browse the repository at this point in the history
1.8.0
  • Loading branch information
OlehDutchenko committed Jan 21, 2020
2 parents 893f5d0 + 544e48f commit 077df95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<img src="https://raw.githubusercontent.com/dutchenkoOleg/storage/master/img/r2d2/r2d2.gif" alt>
> tiny helper
---

Expand Down Expand Up @@ -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)

---

Expand Down
14 changes: 7 additions & 7 deletions src/WezomAgency/R2D2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) : '';
}


Expand Down

0 comments on commit 077df95

Please sign in to comment.