We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 80eb301 commit 142b6d0Copy full SHA for 142b6d0
tests/ArrayHelper/GetValueTest.php
@@ -102,6 +102,13 @@ public function testGetValueByMatcher(): void
102
103
$taggedPost = ArrayHelper::getValue($posts, fn ($post) => isset($post->tag));
104
$this->assertEquals('hello test', $taggedPost->title);
105
+
106
+ $default = ArrayHelper::getValue([], fn ($post) => isset($post->tag), 'default');
107
+ $this->assertEquals($default, 'default');
108
109
+ $this->expectException(InvalidArgumentException::class);
110
+ $this->expectExceptionMessage('Matcher cannot be applied to an object');
111
+ $taggedPost = ArrayHelper::getValue(new StaticObject(), fn ($post) => isset($post->tag));
112
}
113
114
public function dataProviderGetValueByPathFromArray(): array
0 commit comments