BotBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setTelegramApiFactory() 0 5 1
A create() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zored\Telegram\Factory;
6
7
use Zored\Telegram\Bot\BotInterface;
8
use Zored\Telegram\Bot\UpdateBot;
9
10
class BotBuilder
11
{
12
    /**
13
     * @var TelegramApiFactoryInterface|null
14
     */
15
    private $telegramApiFactory;
16
17
    public function create(): BotInterface
18
    {
19
        $this->telegramApiFactory = $this->telegramApiFactory ?? new TelegramApiFactory();
20
21
        return new UpdateBot($this->telegramApiFactory->create());
22
    }
23
24
    public function setTelegramApiFactory(TelegramApiFactoryInterface $telegramApiFactory): self
25
    {
26
        $this->telegramApiFactory = $telegramApiFactory;
27
28
        return $this;
29
    }
30
}
31