Conditions | 7 |
Paths | 9 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
46 | public function __construct(array $data = []) |
||
47 | { |
||
48 | if (!isset($data['keyboard'])) { |
||
49 | throw new TelegramException('Keyboard field is empty!'); |
||
50 | } |
||
51 | |||
52 | if (!is_array($data['keyboard'])) { |
||
53 | throw new TelegramException('Keyboard field is not an array!'); |
||
54 | } |
||
55 | |||
56 | foreach ($data['keyboard'] as $item) { |
||
57 | if (!is_array($item)) { |
||
58 | throw new TelegramException('Keyboard subfield is not an array!'); |
||
59 | } |
||
60 | } |
||
61 | $this->keyboard = $data['keyboard']; |
||
62 | |||
63 | //Set the object members from the passed data params |
||
64 | foreach (['resize_keyboard', 'one_time_keyboard', 'selective'] as $param) { |
||
65 | $this->$param = isset($data[$param]) ? (bool)$data[$param] : false; |
||
66 | } |
||
67 | } |
||
68 | } |
||
69 |