InMemoryServiceRepository::get()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 3
eloc 4
nc 2
nop 1
crap 3
1
<?php
2
3
namespace Gr8abbasi\Container\Repository;
4
5
class InMemoryServiceRepository implements ServiceRepositoryInterface
6
{
7
    /**
8
     * @var array $serviceStore
9
     */
10
    private $serviceStore;
11
12
    /**
13
     * @inheritdoc
14
     */
15 7
    public function get($serviceId)
16
    {
17 7
        if (!isset($this->serviceStore[$serviceId]) || !isset($serviceId)) {
18 6
            return null;
19
        }
20
21 3
        return $this->serviceStore[$serviceId];
22
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27 3
    public function add($id, $service)
28
    {
29 3
        $this->serviceStore[$id] = $service;
30 3
    }
31
}
32