ChannelDriverFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 9
c 1
b 0
f 1
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSupportedTypes() 0 3 1
A create() 0 9 1
1
<?php
2
3
namespace Usamamuneerchaudhary\Notifier\Services;
4
5
use Usamamuneerchaudhary\Notifier\Services\ChannelDrivers\ChannelDriverInterface;
6
use Usamamuneerchaudhary\Notifier\Services\ChannelDrivers\DiscordDriver;
7
use Usamamuneerchaudhary\Notifier\Services\ChannelDrivers\EmailDriver;
8
use Usamamuneerchaudhary\Notifier\Services\ChannelDrivers\PushDriver;
9
use Usamamuneerchaudhary\Notifier\Services\ChannelDrivers\SlackDriver;
10
use Usamamuneerchaudhary\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