Passed
Push — main ( 3b4587...cb10fc )
by Usama
05:39
created

ChannelDriverFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Umun\Notifier\Services;
4
5
use Umun\Notifier\Services\ChannelDrivers\ChannelDriverInterface;
6
use Umun\Notifier\Services\ChannelDrivers\DiscordDriver;
7
use Umun\Notifier\Services\ChannelDrivers\EmailDriver;
8
use Umun\Notifier\Services\ChannelDrivers\PushDriver;
9
use Umun\Notifier\Services\ChannelDrivers\SlackDriver;
10
use Umun\Notifier\Services\ChannelDrivers\SmsDriver;
11
12
class ChannelDriverFactory
13
{
14
    /**
15
     * Create a driver instance for the given channel type
16
     */
17
    public function create(string $channelType): ?ChannelDriverInterface
18
    {
19
        return match ($channelType) {
20
            'email' => new EmailDriver(),
21
            'slack' => new SlackDriver(),
22
            'sms' => new SmsDriver(),
23
            'push' => new PushDriver(),
24
            'discord' => new DiscordDriver(),
25
            default => null,
26
        };
27
    }
28
29
    /**
30
     * Get all supported channel types
31
     */
32
    public function getSupportedTypes(): array
33
    {
34
        return ['email', 'slack', 'sms', 'push', 'discord'];
35
    }
36
}
37
38
39