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

Factory::getInstance()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
crap 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