Completed
Push — master ( 0cb834...ce1742 )
by Camilo
04:29
created

TelegramMethods::performSpecialConditions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace unreal4u\Abstracts;
6
7
use unreal4u\Interfaces\TelegramMethodDefinitions;
8
9
/**
10
 * Contains methods that all Telegram methods should implement
11
 */
12
abstract class TelegramMethods implements TelegramMethodDefinitions
13
{
14
    /**
15
     * Most of the methods will return a Message object on success, so set that as default.
16
     *
17
     * @return string
18
     */
19 15
    public static function bindToObjectType(): string
20
    {
21 15
        return 'Message';
22
    }
23
24
    /**
25
     * Special transformations can be done in this method, before making the actual request this method will be called
26
     * @return TelegramMethods
27
     */
28 21
    public function performSpecialConditions(): TelegramMethods
29
    {
30 21
        if (!empty($this->reply_markup)) {
31 1
            $this->reply_markup = json_encode($this->reply_markup);
1 ignored issue
show
Bug introduced by
The property reply_markup does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
32
        }
33
34 21
        return $this;
35
    }
36
}
37