SystemFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 40
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 10 2
A getSystem() 0 8 2
1
<?php
2
3
namespace League\CLImate\Util\System;
4
5
class SystemFactory
6
{
7
    /**
8
     * @var \League\CLImate\Util\System\System $instance
9
     */
10
11
    protected static $instance;
12
13
    /**
14
     * Get an instance of the appropriate System class
15
     *
16
     * @return \League\CLImate\Util\System\System
17
     */
18
19 948
    public static function getInstance()
20
    {
21 948
        if (static::$instance) {
22 944
            return static::$instance;
23
        }
24
25 4
        static::$instance = self::getSystem();
26
27 4
        return static::$instance;
28
    }
29
30
    /**
31
     * Set the $instance property to the appropriate system
32
     *
33
     * @return \League\CLImate\Util\System\System
34
     */
35
36 4
    protected static function getSystem()
37
    {
38 4
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
39
            return new Windows();
40
        }
41
42 4
        return new Linux();
43
    }
44
}
45