Skip to content

Commit 972c5f4

Browse files
committed
add dump & dd methods
1 parent e400365 commit 972c5f4

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ $this->group('a')->validate(); // validates all properties in a group
4949
$this->group(['a', 'b']); // operations can be applied to any number of groups
5050
$this->group(['a', 'b'])->validate(); // especially handy when validating
5151

52+
$this->group('a')->dump();
53+
$this->group('a')->dd();
5254
```
5355

5456
## Development

src/PropertyCollection.php

+20
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
use ArrayIterator;
88
use IteratorAggregate;
99
use Livewire\Component;
10+
use Illuminate\Support\Traits\Dumpable;
1011

1112
class PropertyCollection implements ArrayAccess, IteratorAggregate
1213
{
14+
use Dumpable;
15+
1316
final public function __construct(
1417
private readonly Component $component,
1518
private array $items = []
@@ -79,6 +82,23 @@ public function validate()
7982
return $this->component->validate($rules);
8083
}
8184

85+
/*
86+
|--------------------------------------------------------------------------
87+
| dump & dd
88+
|--------------------------------------------------------------------------
89+
*/
90+
public function dump(): self
91+
{
92+
dump($this->items);
93+
94+
return $this;
95+
}
96+
97+
public function dd(): never
98+
{
99+
dd($this->items);
100+
}
101+
82102
/*
83103
|--------------------------------------------------------------------------
84104
| ArrayAccess/Iterator methods

tests/Unit/MacroTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Tests\TestComponent;
44
use Leuverink\PropertyAttribute\Group;
5+
use Leuverink\PropertyAttribute\PropertyCollection;
56

67
use function Leuverink\PropertyAttribute\group;
78

@@ -94,3 +95,8 @@
9495

9596
expect($result)->toBeArray();
9697
});
98+
99+
arch('it is dumpable')
100+
->expect(PropertyCollection::class)
101+
->toHaveMethod('dump')
102+
->toHaveMethod('dd');

0 commit comments

Comments
 (0)