Factory::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Prophecy.
5
 * (c) Konstantin Kudryashov <[email protected]>
6
 *     Marcello Duarte <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Prophecy\Comparator;
13
14
use SebastianBergmann\Comparator\Factory as BaseFactory;
15
16
/**
17
 * Prophecy comparator factory.
18
 *
19
 * @author Konstantin Kudryashov <[email protected]>
20
 */
21
final class Factory extends BaseFactory
22
{
23
    /**
24
     * @var Factory
25
     */
26
    private static $instance;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
27
28
    public function __construct()
29
    {
30
        parent::__construct();
31
32
        $this->register(new ClosureComparator());
33
        $this->register(new ProphecyComparator());
34
    }
35
36
    /**
37
     * @return Factory
38
     */
39
    public static function getInstance()
40
    {
41
        if (self::$instance === null) {
42
            self::$instance = new Factory;
43
        }
44
45
        return self::$instance;
46
    }
47
}
48