Completed
Pull Request — develop (#291)
by Armando
03:42
created

InlineKeyboard::validate()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 8

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 5

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 16
loc 16
ccs 9
cts 9
cp 1
rs 8.8571
cc 5
eloc 8
nc 5
nop 0
crap 5
1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Entities;
12
13
use Longman\TelegramBot\Exception\TelegramException;
14
15
/**
16
 * Class InlineKeyboard
17
 *
18
 * @link https://core.telegram.org/bots/api#inlinekeyboardmarkup
19
 */
20
class InlineKeyboard extends Keyboard
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 7
    public function __construct($data = [])
26
    {
27 7
        $data = call_user_func_array([$this, 'createFromParams'], func_get_args());
28 7
        parent::__construct($data);
29 5
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 7 View Code Duplication
    protected function validate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
    {
36 7
        $inline_keyboard = $this->getProperty('inline_keyboard');
37
38 7
        if ($inline_keyboard !== null) {
39 7
            if (!is_array($inline_keyboard)) {
40 1
                throw new TelegramException('Inline Keyboard field is not an array!');
41
            }
42
43 6
            foreach ($inline_keyboard as $item) {
44 6
                if (!is_array($item)) {
45 6
                    throw new TelegramException('Inline Keyboard subfield is not an array!');
46
                }
47
            }
48
        }
49 5
    }
50
}
51