Completed
Push — master ( f4f000...4f389f )
by Thijs
01:49 queued 11s
created

MetaData::__set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace TestMonitor\Custify\Resources;
4
5
class MetaData extends Resource
6
{
7
    /**
8
     * The metadata.
9
     *
10
     * @var array
11
     */
12
    public $metadata;
13
14
    /**
15
     * Create a new resource instance.
16
     *
17
     * @param array $metadata
18
     */
19 2
    public function __construct($metadata = [])
20
    {
21 2
        $this->metadata = $metadata;
22 2
    }
23
24
    /**
25
     * Gets a meta data item.
26
     *
27
     * @param $name
28
     *
29
     * @return mixed|null
30
     */
31
    public function __get($name)
32
    {
33
        return $this->metadata[$name] ?? null;
34
    }
35
36
    /**
37
     * Sets a meta data item.
38
     *
39
     * @param string $name
40
     * @param mixed $value
41
     */
42
    public function __set($name, $value)
43
    {
44
        $this->metadata[$name] = $value;
45
    }
46
47
    /**
48
     * Returns the custom attributes as a key/value array.
49
     *
50
     * @return object
51
     */
52 2
    public function toObject(): object
53
    {
54 2
        return (object) $this->metadata;
55
    }
56
}
57