Skip to content

Commit ea6fa9c

Browse files
committed
Update phpdoc annotations
1 parent 8c456b9 commit ea6fa9c

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

src/ResourceIdentifierInterface.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@
55

66
namespace tuyakhov\jsonapi;
77

8+
/**
9+
* Interface for a “resource identifier object” that identifies an individual resource.
10+
*/
811
interface ResourceIdentifierInterface
912
{
13+
/**
14+
* The "id" member of a resource object.
15+
* @return string an ID that in pair with type uniquely identifies the resource.
16+
*/
1017
public function getId();
1118

19+
/**
20+
* The "type" member of a resource object.
21+
* @return string a type that identifies the resource.
22+
*/
1223
public function getType();
1324
}

src/ResourceInterface.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@
55

66
namespace tuyakhov\jsonapi;
77

8+
/**
9+
* Interface for a “resource object” that represent an individual resource.
10+
*/
811
interface ResourceInterface extends ResourceIdentifierInterface
912
{
13+
/**
14+
* The "attributes" member of the resource object representing some of the resource’s data.
15+
* @param array $fields specific fields that a client has requested.
16+
* @return array an array of attributes that represent information about the resource object in which it’s defined.
17+
*/
1018
public function getResourceAttributes(array $fields = []);
1119

20+
/**
21+
* The "relationships" member of the resource object describing relationships between the resource and other JSON API resources.
22+
* @return ResourceIdentifierInterface[] represent references from the resource object in which it’s defined to other resource objects.
23+
*/
1224
public function getResourceRelationships();
1325

1426
public function setResourceRelationship($name, $relationship);

src/ResourceTrait.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
trait ResourceTrait
1515
{
1616
/**
17-
* @return null|string
17+
* @return string
1818
*/
1919
public function getId()
2020
{
21-
if ($this instanceof ActiveRecordInterface) {
22-
return (string) $this->getPrimaryKey();
23-
}
24-
return null;
21+
return (string) ($this instanceof ActiveRecordInterface ? $this->getPrimaryKey() : null);
2522
}
2623

2724
/**

tests/data/ResourceModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ResourceModel extends Model implements ResourceInterface, LinksInterface
2929

3030
public function getId()
3131
{
32-
return static::$id;
32+
return (string) static::$id;
3333
}
3434

3535
public function fields()

0 commit comments

Comments
 (0)