ServiceFactory::inst()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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