Completed
Push — master ( fbc01c...6057b3 )
by Westin
15s
created

ServiceTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getService() 0 16 3
1
<?php
2
3
namespace WShafer\PSR11MonoLog;
4
5
use WShafer\PSR11MonoLog\Exception\MissingConfigException;
6
use WShafer\PSR11MonoLog\Exception\MissingServiceException;
7
8
trait ServiceTrait
9
{
10
    use ContainerTrait;
11
12 3
    public function getService($name)
13
    {
14 3
        if (empty($name)) {
15 1
            throw new MissingConfigException(
16 1
                'No service name found in config'
17
            );
18
        }
19
20 2
        if (!$this->getContainer()->has($name)) {
21 1
            throw new MissingServiceException(
22 1
                'No service found for :'.$name
23
            );
24
        }
25
26 1
        return $this->getContainer()->get($name);
27
    }
28
}
29