BotBuilder::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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