Skip to content

Commit b1d4215

Browse files
committed
Add dot-notation in docs and changelog
1 parent f07119e commit b1d4215

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased][]
77

8+
### Added
9+
10+
- Dot-notation support in `AccessInterface::has()` and `AccessInterface::get()`
11+
812
## [0.4] - 2015-09-01
913

1014
### Added

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Format: [JSON API 1.0](http://jsonapi.org/format/1.0/)
1414

1515
* [x] Be 100% JSON API 1.0 spec conform
1616
* [x] Handle/validate a server response body
17-
* [ ] Offer an easy way to retrieve the data
17+
* [x] Offer an easy way to retrieve the data
1818
* [x] Be extendable and allow injection of classes/models
1919
* [ ] Offer access to included resources through identifier
2020
* [ ] Handle/validate a client request body
@@ -41,9 +41,9 @@ $manager = new \Art4\JsonApiClient\Utils\Manager();
4141

4242
$document = $manager->parse($jsonapi_string);
4343

44-
if ($document->has('meta') and $document->get('meta')->has('info'))
44+
if ($document->has('meta.info'))
4545
{
46-
echo $document->get('meta')->get('info'); // "Testing the JSON API Client."
46+
echo $document->get('meta.info'); // "Testing the JSON API Client."
4747
}
4848

4949
// List all keys

docs/objects-introduction.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ This returns:
6565
bool(true)
6666
```
6767

68+
The `has()` method has support for dot-notated keys:
69+
70+
```php
71+
var_dump($document->has('meta.info'));
72+
var_dump($document->has('jsonapi.version'));
73+
```
74+
75+
This returns:
76+
77+
```php
78+
bool(true)
79+
bool(false)
80+
```
81+
6882
### Get the keys of all existing values
6983

7084
You can get the keys of all existing values using the `getKeys()` method. Assume we have the same `$document` like in the last example.
@@ -102,6 +116,18 @@ $meta = $document->get('meta');
102116

103117
> **Note:** Using `get()` on a non-existing value will throw an [Exception\AccessException](exception-introduction.md#exceptionaccessexception). Use `has()` or `getKeys()` to check if a value exists.
104118
119+
The `get()` method has support for dot-notated keys:
120+
121+
```php
122+
var_dump($document->get('meta.info'));
123+
```
124+
125+
This returns:
126+
127+
```php
128+
string(28) "Testing the JSON API Client."
129+
```
130+
105131
### Get the containing data as array
106132

107133
You can get all data as an array using the `asArray()` method.

0 commit comments

Comments
 (0)