Model::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Groove;
4
5
use JsonSerializable;
6
7
abstract class Model implements JsonSerializable
8
{
9
    /**
10
     * @var \stdClass
11
     */
12
    protected $details;
13
14
    /**
15
     * @var \Groove\Client
16
     */
17
    protected $client;
18
19
    /**
20
     * Model.
21
     *
22
     * @param \stdClass $details
23
     * @param \Groove\Client $client
24
     */
25
    public function __construct($details, $client)
26
    {
27
        $this->details = $details;
28
        $this->client = $client;
29
    }
30
31
    /**
32
     * Serialize json.
33
     *
34
     * @return \stdClass
35
     */
36
    public function jsonSerialize()
37
    {
38
        return $this->details;
39
    }
40
41
    /**
42
     * To string.
43
     *
44
     * @return string
45
     */
46
    public function __toString()
47
    {
48
        return json_encode($this->details);
49
    }
50
51
    /**
52
     * Get property.
53
     *
54
     * @param  string $key
55
     * @return mixed
56
     */
57
    public function __get($key)
58
    {
59
        return $this->details->$key;
60
    }
61
}
62