BotFactory   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\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