BotFactory::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\Bot\Factory;
6
7
use Zored\Telegram\Bot\BotInterface;
8
use Zored\Telegram\Bot\UpdateBot;
9
use Zored\Telegram\Factory\TelegramApiFactory;
10
use Zored\Telegram\Factory\TelegramApiFactoryInterface;
11
12
class BotFactory
13
{
14
    /**
15
     * @var TelegramApiFactoryInterface|null
16
     */
17
    private $telegramApiFactory;
18
19
    public function create(): BotInterface
20
    {
21
        $this->telegramApiFactory = $this->telegramApiFactory ?? new TelegramApiFactory();
22
23
        return new UpdateBot($this->telegramApiFactory->create());
24
    }
25
26
    public function setTelegramApiFactory(TelegramApiFactoryInterface $telegramApiFactory): self
27
    {
28
        $this->telegramApiFactory = $telegramApiFactory;
29
30
        return $this;
31
    }
32
}
33