Code Duplication    Length = 62-62 lines in 2 locations

src/Document/Behaviour/AttributesContainer.php 1 location

@@ 13-74 (lines=62) @@
10
 *
11
 * @package Mikemirten\Component\JsonApi\Document\Behaviour
12
 */
13
trait AttributesContainer
14
{
15
    /**
16
     * Attributes
17
     *
18
     * @var array
19
     */
20
    protected $attributes = [];
21
22
    /**
23
     * Set attribute
24
     *
25
     * @param string $name
26
     * @param mixed  $value
27
     */
28
    public function setAttribute(string $name, $value)
29
    {
30
        $this->attributes[$name] = $value;
31
    }
32
33
    /**
34
     * Has attribute
35
     *
36
     * @param  string $name
37
     * @return bool
38
     */
39
    public function hasAttribute(string $name): bool
40
    {
41
        return array_key_exists($name, $this->attributes);
42
    }
43
44
    /**
45
     * Get attribute
46
     *
47
     * @param  string $name
48
     * @return mixed
49
     */
50
    public function getAttribute(string $name)
51
    {
52
        return $this->attributes[$name];
53
    }
54
55
    /**
56
     * Contains any attributes ?
57
     *
58
     * @return bool
59
     */
60
    public function hasAttributes(): bool
61
    {
62
        return count($this->attributes) > 0;
63
    }
64
65
    /**
66
     * Get all attributes
67
     *
68
     * @return array
69
     */
70
    public function getAttributes(): array
71
    {
72
        return $this->attributes;
73
    }
74
}

src/Document/Behaviour/MetadataContainer.php 1 location

@@ 13-74 (lines=62) @@
10
 *
11
 * @package Mikemirten\Component\JsonApi\Document\Behaviour
12
 */
13
trait MetadataContainer
14
{
15
    /**
16
     * Metadata attributes
17
     *
18
     * @var array
19
     */
20
    protected $metadata = [];
21
22
    /**
23
     * Set attribute of metadata
24
     *
25
     * @param string $name
26
     * @param $value
27
     */
28
    public function setMetadataAttribute(string $name, $value)
29
    {
30
        $this->metadata[$name] = $value;
31
    }
32
33
    /**
34
     * Has attribute of metadata
35
     *
36
     * @param  string $name
37
     * @return bool
38
     */
39
    public function hasMetadataAttribute(string $name): bool
40
    {
41
        return array_key_exists($name, $this->metadata);
42
    }
43
44
    /**
45
     * Get attribute of metadata
46
     *
47
     * @param string $name
48
     * @return mixed
49
     */
50
    public function getMetadataAttribute(string $name)
51
    {
52
        return $this->metadata[$name];
53
    }
54
55
    /**
56
     * Contains any metadata ?
57
     *
58
     * @return bool
59
     */
60
    public function hasMetadata(): bool
61
    {
62
        return count($this->metadata) > 0;
63
    }
64
65
    /**
66
     * Get all attributes of metadata
67
     *
68
     * @return array
69
     */
70
    public function getMetadata(): array
71
    {
72
        return $this->metadata;
73
    }
74
}