Completed
Pull Request — 1.0 (#2)
by David
04:25
created

ServiceFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 1
1
<?php
2
3
4
namespace TheCodingMachine\Yaco\ServiceProvider;
5
6
/**
7
 * This utility class is used to instantiate services from a service provider (if the services are not
8
 * static methods).
9
 *
10
 * Note: this calls the 'getServices' method of the service provider. Hence, this is suboptimal compared to
11
 * a call to a static method
12
 */
13
class ServiceFactory
14
{
15
    public function create(string $serviceProviderClassName, string $serviceName, array $params)
16
    {
17
        $services = call_user_func([$serviceProviderClassName, 'getServices']);
18
19
        return call_user_func_array($services[$serviceName], $params);
20
    }
21
}
22