Completed
Pull Request — develop (#291)
by Armando
13:31
created

InlineEntity   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 0 13 2
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\InlineQuery;
12
13
use Longman\TelegramBot\Entities\Entity;
14
15
abstract class InlineEntity extends Entity
16
{
17
    /**
18
     * Magic method to set properties dynamically
19
     *
20
     * @param $method
21
     * @param $args
22
     *
23
     * @return \Longman\TelegramBot\Entities\InlineQuery\InlineEntity
24
     */
25
    public function __call($method, $args)
26
    {
27
        $action = substr($method, 0, 3);
28
        if ($action === 'set') {
29
            //Convert method to snake_case (which is the name of the property)
30
            $property_name        = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', substr($method, 3))), '_');
31
            $this->$property_name = $args[0];
32
33
            return $this;
34
        }
35
36
        return parent::__call($method, $args);
37
    }
38
}
39