Skip to content

Add `find` method

Compare
Choose a tag to compare
@alwaysblank alwaysblank released this 30 Sep 17:15
· 51 commits to master since this release
caa0b45

The find method opens up some interesting possibilities when dealing with keyed arrays. It is called like so:

$Brief = new Brief(['key2' => 'value']);
echo $Brief->find('key1', 'key2');
// value

It receives an array of keys, and will return the value for the first key it can match, going from left to right. With a little work, this can allow you to do things like alias keys (i.e. item => itemprop) or set defaults by extending the Brief class, or creating "base" Brief instances and then copying and modifying them.