Code Duplication    Length = 25-25 lines in 2 locations

src/Document/AbstractDocument.php 1 location

@@ 21-45 (lines=25) @@
18
 *
19
 * @package Mikemirten\Component\JsonApi\Document
20
 */
21
abstract class AbstractDocument implements MetadataAwareInterface, LinksAwareInterface
22
{
23
    use MetadataContainer;
24
    use LinksContainer;
25
26
    /**
27
     * Cast to an array
28
     *
29
     * @return array
30
     */
31
    public function toArray(): array
32
    {
33
        $data = [];
34
35
        if ($this->hasMetadata()) {
36
            $data['meta'] = $this->getMetadata();
37
        }
38
39
        if ($this->hasLinks()) {
40
            $data['links'] = $this->linksToArray();
41
        }
42
43
        return $data;
44
    }
45
}

src/Document/AbstractRelationship.php 1 location

@@ 21-45 (lines=25) @@
18
 *
19
 * @package Mikemirten\Component\JsonApi\Document
20
 */
21
abstract class AbstractRelationship implements MetadataAwareInterface, LinksAwareInterface
22
{
23
    use MetadataContainer;
24
    use LinksContainer;
25
26
    /**
27
     * Cast to an array
28
     *
29
     * @return array
30
     */
31
    public function toArray(): array
32
    {
33
        $data = [];
34
35
        if ($this->hasMetadata()) {
36
            $data['meta'] = $this->getMetadata();
37
        }
38
39
        if ($this->hasLinks()) {
40
            $data['links'] = $this->linksToArray();
41
        }
42
43
        return $data;
44
    }
45
}