Conditions | 6 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6 |
1 | <?php |
||
20 | 14 | final protected function populateObject(\stdClass $data = null): TelegramTypes |
|
21 | { |
||
22 | 14 | if (!is_null($data)) { |
|
23 | 14 | $subObjects = $this->mapSubObjects(); |
|
24 | 14 | foreach ($data as $key => $value) { |
|
|
|||
25 | 14 | if (!empty($subObjects) && array_key_exists($key, $subObjects)) { |
|
26 | 12 | $className = 'unreal4u\\Telegram\\Types\\' . $subObjects[$key]; |
|
27 | 12 | $candidateKey = new $className($value); |
|
28 | 12 | if (isset($candidateKey->data)) { |
|
29 | 4 | $this->$key = $candidateKey->data; |
|
30 | } else { |
||
31 | 12 | $this->$key = $candidateKey; |
|
32 | } |
||
33 | } else { |
||
34 | 14 | $this->$key = $value; |
|
35 | } |
||
36 | } |
||
37 | } |
||
38 | |||
39 | 14 | return $this; |
|
40 | } |
||
41 | |||
52 |