Completed
Push — master ( e9be36...9488e8 )
by Camilo
04:57
created

ResultBoolean   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 10
ccs 4
cts 4
cp 1
rs 10
c 4
b 1
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace unreal4u\TelegramAPI\Telegram\Types\Custom;
5
6
use unreal4u\TelegramAPI\Abstracts\CustomType;
7
use Psr\Log\LoggerInterface;
8
9
/**
10
 * Some APIs (mainly inline bots) respond with boolean types
11
 */
12
class ResultBoolean extends CustomType
13
{
14
    public $data = false;
15
16 2
    public function __construct(bool $result, LoggerInterface $logger = null)
17
    {
18 2
        $this->logger = $logger;
19 2
        $this->data = $result;
20 2
    }
21
22
    /**
23
     * I don't really use this function, but I can imagine it can come in handy when PHP handles the casting internally
24
     * @return string
25
     */
26
    public function __toString()
27
    {
28
        if ($this->data === true) {
29
            return '1';
30
        } else {
31
            return '0';
32
        }
33
    }
34
}
35