Passed
Push — master ( b87842...405697 )
by Stan
04:32
created

MessengerClientFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Skater4\LaravelSentryNotifications\Services\Messengers\Factories;
4
5
use Skater4\LaravelSentryNotifications\Enum\Services;
6
use Skater4\LaravelSentryNotifications\Exceptions\UnknownServiceException;
7
use Skater4\LaravelSentryNotifications\Services\Messengers\Clients\Telegram\TelegramClient;
8
use Skater4\LaravelSentryNotifications\Services\Messengers\Interfaces\MessengerClientInterface;
9
10
class MessengerClientFactory
11
{
12
    private $service;
13
14
    public function __construct(string $service)
15
    {
16
        $this->service = $service;
17
    }
18
19
    public function create(): MessengerClientInterface
20
    {
21
        switch ($this->service) {
22
            case Services::SERVICE_TELEGRAM:
23
                return app(TelegramClient::class);
24
            default:
25
                throw new UnknownServiceException('Unknown service ' . $this->service);
26
        }
27
    }
28
}
29