Passed
Push — main ( 383cbf...40aa9a )
by Dylan
02:01
created

ServiceFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A inst() 0 7 2
1
<?php
2
3
namespace Lifeboat\Factory;
4
5
use Lifeboat\Connector;
6
use Lifeboat\Services\ApiService;
7
8
/**
9
 * Class ServiceFactory
10
 * @package Lifeboat\Services
11
 */
12
class ServiceFactory {
13
14
    const CLASS_MAP = [
15
        'orders'    => \Lifeboat\Services\Orders::class
16
    ];
17
18
    /**
19
     * @param Connector $connector
20
     * @param string $service
21
     * @return ApiService|null
22
     */
23
    public static function inst(Connector $connector, string $service): ?ApiService
24
    {
25
        $service = strtolower($service);
26
        if (!array_key_exists($service, self::CLASS_MAP)) return null;
27
28
        $cls = self::CLASS_MAP[$service];
29
        return new $cls($connector);
30
    }
31
}
32