ChannelDriverFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 9
rs 10
cc 1
nc 1
nop 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