ServiceFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 14
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
    /**
15
     * @param Connector $connector
16
     * @param string $service
17
     * @return ApiService|null
18
     */
19
    public static function inst(Connector $connector, string $service): ?ApiService
20
    {
21
        $service = strtolower($service);
22
        if (!array_key_exists($service, ClassMap::SERVICES)) return null;
23
24
        $cls = ClassMap::SERVICES[$service];
25
        return new $cls($connector);
26
    }
27
}
28