Skip to content

Commit

Permalink
Add getListItemAttributes() method to HasListItem::class. (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Sep 12, 2023
1 parent 6ed55b4 commit 51550a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Attribute/Component/HasListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ trait HasListItem
{
protected array $listItemAttributes = [];

/**
* Get the `HTML` attributes for tag `<li>`.
*
* @return array Attribute values indexed by attribute names.
*/
public function getListItemAttributes(): array
{
return $this->listItemAttributes;
}

/**
* Set the `HTML` attributes for tag `<li>`.
*
Expand Down
13 changes: 13 additions & 0 deletions tests/Attribute/Component/HasListItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ public function getListItemClass(): string
$this->assertSame('foo bar', $instance->getListItemClass());
}

public function testGetListItemAttributes(): void
{
$instance = new class() {
use HasListItem;
};

$this->assertEmpty($instance->getListItemAttributes());

$instance = $instance->listItemAttributes(['foo' => 'bar']);

$this->assertSame(['foo' => 'bar'], $instance->getListItemAttributes());
}

public function testImmutablity(): void
{
$instance = new class() {
Expand Down

0 comments on commit 51550a0

Please sign in to comment.