InlineBaseObject::__call()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 6
cp 0
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
namespace Telegram\Bot\Objects\InlineQuery;
3
4
use BadMethodCallException;
5
use Illuminate\Support\Collection;
6
use Illuminate\Support\Str;
7
8
abstract class InlineBaseObject extends Collection
9
{
10
11
    /**
12
     * Magic method to set properties dynamically.
13
     *
14
     * @param $name
15
     * @param $arguments
16
     *
17
     * @return $this|mixed
18
     */
19
    public function __call($name, $arguments)
20
    {
21
        $action = substr($name, 0, 3);
22
23
        if ($action === 'set') {
24
            $property = Str::snake(substr($name, 3));
25
            $this->put($property, $arguments[0]);
26
27
            return $this;
28
        }
29
30
        throw new BadMethodCallException("Method {$name} does not exist.");
31
    }
32
}
33