Skip to content

Commit 3173174

Browse files
committed
Minor changes to object interfaces.
1 parent 650735d commit 3173174

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

src/Contracts/Object/Relationships/RelationshipInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
use CloudCreativity\JsonApi\Contracts\Object\ResourceIdentifier\ResourceIdentifierCollectionInterface;
2222
use CloudCreativity\JsonApi\Contracts\Object\ResourceIdentifier\ResourceIdentifierInterface;
23+
use CloudCreativity\JsonApi\Contracts\Object\StandardObjectInterface;
2324
use RuntimeException;
2425

2526
/**
@@ -43,9 +44,15 @@ public function getData();
4344

4445
/**
4546
* @return bool
47+
* @deprecated use `isHasOne` instead
4648
*/
4749
public function isBelongsTo();
4850

51+
/**
52+
* @return bool
53+
*/
54+
public function isHasOne();
55+
4956
/**
5057
* @return bool
5158
*/

src/Contracts/Object/StandardObjectInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public function get($key, $default = null);
3939
*/
4040
public function getProperties(array $keys, $default = null);
4141

42+
/**
43+
* Get properties if they exist.
44+
*
45+
* @param array $keys
46+
* @return array
47+
*/
48+
public function getMany(array $keys);
49+
4250
/**
4351
* @param $key
4452
* @param $value

src/Object/ObjectProxyTrait.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ public function getProperties(array $keys, $default = null)
8383
return $ret;
8484
}
8585

86+
/**
87+
* Get properties if they exist.
88+
*
89+
* @param array $keys
90+
* @return array
91+
*/
92+
public function getMany(array $keys)
93+
{
94+
$ret = [];
95+
96+
foreach ($keys as $key) {
97+
98+
if ($this->has($key)) {
99+
$ret[$key] = $this->get($key);
100+
}
101+
}
102+
103+
return $ret;
104+
}
105+
86106
/**
87107
* @param $key
88108
* @param $value

src/Object/Relationships/Relationship.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,17 @@ public function getData()
5252
}
5353

5454
/**
55-
* @return bool
55+
* @inheritdoc
5656
*/
5757
public function isBelongsTo()
58+
{
59+
return $this->isHasOne();
60+
}
61+
62+
/**
63+
* @return bool
64+
*/
65+
public function isHasOne()
5866
{
5967
if (!$this->has(static::DATA)) {
6068
return false;

0 commit comments

Comments
 (0)