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

MessengerClientFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 2
A __construct() 0 3 1
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