From 56ebda102ef4552aa6bb1ad65e9b2a32e3915f30 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Fri, 30 Jun 2023 19:46:10 +0200 Subject: [PATCH] add readme --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 986a269..26effba 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,10 @@ The package will automatically register itself. - [`firstOrFail`](#firstorfail) - [`firstOrPush`](#firstorpush) - [`fromPairs`](#frompairs) +- [`getCaseInsensitive`](#getcaseinsensitive) - [`glob`](#glob) - [`groupByModel`](#groupbymodel) +- [`hasCaseInsensitive`](#hascaseinsensitive) - [`head`](#head) - [`if`](#if) - [`ifAny`](#ifany) @@ -384,6 +386,20 @@ $collection = collect([['a', 'b'], ['c', 'd'], ['e', 'f']])->fromPairs(); $collection->toArray(); // returns ['a' => 'b', 'c' => 'd', 'e' => 'f'] ``` +### `getCaseInsensitive` + +Get the value of a given key. + +If the key is a string, we'll search for the key using a case-insensitive comparison. + +```php +$collection = collect([ + 'foo' => 'bar', +]); + +$collection->getCaseInsensitive('Foo'); // returns 'bar'; +``` + ### `glob` Returns a collection of a `glob()` result. @@ -407,6 +423,20 @@ $posts->groupByModel('category'); Full signature: `groupByModel($callback, $preserveKeys, $modelKey, $itemsKey)` +### `hasCaseInsensitive` + +Determine if the collection contains a key with a given name. + +If $key is a string, we'll search for the key using a case-insensitive comparison. + +```php +$collection = collect([ + 'foo' => 'bar', +]); + +$collection->hasCaseInsensitive('Foo'); // returns true; +``` + ### `head` Retrieves first item from the collection.