Completed
Push — master ( 9e6269...55e422 )
by Gareth
04:08
created

Factory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 16 3
1
<?php
2
3
namespace garethp\ews\HttpPlayback;
4
5
class Factory
6
{
7
    private static $instances = [];
8
9 36
    public static function getInstance($options = [])
10
    {
11 36
        foreach (self::$instances as $instance) {
12 36
            if ($instance['options'] == $options) {
13 36
                return $instance['instance'];
14
            }
15
        }
16
17 32
        $instance = new Client($options);
18 29
        self::$instances[] = [
19 29
            'instance' => $instance,
20 29
            'options' => $options
21
        ];
22
23 29
        return $instance;
24
    }
25
}
26