Code Duplication    Length = 24-25 lines in 2 locations

src/Keyboard/Base.php 1 location

@@ 6-29 (lines=24) @@
3
4
use Illuminate\Support\Collection;
5
6
class Base extends Collection
7
{
8
    /**
9
     * Dynamically build params.
10
     *
11
     * @param string $method
12
     * @param array  $args
13
     *
14
     * @return $this
15
     */
16
    public function __call($method, $args)
17
    {
18
        $action = substr($method, 0, 3);
19
20
        if ($action === 'set') {
21
            $property = snake_case(substr($method, 3));
22
            $this->items[$property] = $args[0];
23
24
            return $this;
25
        }
26
27
        parent::__call($method, $args);
28
    }
29
}
30

src/Objects/InlineQuery/InlineBaseObject.php 1 location

@@ 7-31 (lines=25) @@
4
use BadMethodCallException;
5
use Illuminate\Support\Collection;
6
7
abstract class InlineBaseObject extends Collection
8
{
9
10
    /**
11
     * Magic method to set properties dynamically.
12
     *
13
     * @param $name
14
     * @param $arguments
15
     *
16
     * @return $this|mixed
17
     */
18
    public function __call($name, $arguments)
19
    {
20
        $action = substr($name, 0, 3);
21
22
        if ($action === 'set') {
23
            $property = snake_case(substr($name, 3));
24
            $this->put($property, $arguments[0]);
25
26
            return $this;
27
        }
28
29
        throw new BadMethodCallException("Method {$name} does not exist.");
30
    }
31
}
32