Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 20 |
AbstractObject | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
182 | |
0.00% |
0 / 20 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
set | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 4 |
|||
__get | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
__set | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
getId | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
setId | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
all | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 5 |
1 | <?php |
2 | |
3 | |
4 | namespace Qmp\Laravel\CDNApi\Cdn\KeyCDNProvider; |
5 | |
6 | |
7 | abstract class AbstractObject |
8 | { |
9 | protected $data = []; |
10 | |
11 | protected $searchId = null; |
12 | |
13 | public function __construct(array $data = []) |
14 | { |
15 | $this->set($data); |
16 | } |
17 | |
18 | public function set(array $data = []) |
19 | { |
20 | foreach ($data as $key => $item) { |
21 | if (array_key_exists($key, $this->data)) { |
22 | $this->data[$key] = $item; |
23 | } |
24 | } |
25 | } |
26 | |
27 | public function __get(string $key) |
28 | { |
29 | if (!array_key_exists($key, $this->data)) { |
30 | return null; |
31 | } |
32 | |
33 | return $this->data[$key]; |
34 | } |
35 | |
36 | public function __set(string $key, $data) |
37 | { |
38 | if (array_key_exists($key, $this->data)) { |
39 | $this->data[$key] = $data; |
40 | } |
41 | } |
42 | |
43 | public function getId() |
44 | { |
45 | return $this->searchId; |
46 | } |
47 | |
48 | public function setId($id) |
49 | { |
50 | $this->searchId = $id; |
51 | } |
52 | |
53 | public function all() |
54 | { |
55 | $result = []; |
56 | |
57 | foreach ($this->data as $key => $value) { |
58 | if ($value !== null) { |
59 | $result[$key] = $value; |
60 | } |
61 | } |
62 | |
63 | return $result; |
64 | } |
65 | } |