TransportFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 21
ccs 10
cts 10
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 4
1
<?php
2
3
namespace Da\Mailer\Transport;
4
5
use Da\Mailer\Enum\TransportType;
6
use Da\Mailer\Exception\InvalidTransportTypeArgumentException;
7
8
class TransportFactory
9
{
10
    /**
11
     * Creates one of the transport supported according to the type passed.
12
     *
13
     * @param array $options the options to configure the transport
14
     * @param string $type the type of transport
15
     *
16 2
     * @return MailTransportFactory|SendMailTransportFactory|SmtpTransportFactory
17
     */
18
    public static function create(array $options, $type)
19 2
    {
20 1
        switch ($type) {
21 2
            case TransportType::SEND_MAIL:
22 1
                return new SendMailTransportFactory($options);
23 2
            case TransportType::MAIL:
24 1
                return new MailTransportFactory($options);
25 1
            case TransportType::SMTP:
26 1
                return new SmtpTransportFactory($options);
27 1
            default:
28
                throw new InvalidTransportTypeArgumentException("Unknown TransportType: '{$type}'");
29
        }
30
    }
31
}
32