NoValueMonad::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Smoren\PartialIntersection\Util;
4
5
/**
6
 * Based on IterTools PHP's IteratorFactory.
7
 * @see https://github.com/markrogoyski/itertools-php
8
 * @see https://github.com/markrogoyski/itertools-php/blob/main/src/Util/NoValueMonad.php
9
 */
10
class NoValueMonad
11
{
12
    private static ?self $instance = null;
13
14 238
    public static function getInstance(): self
15
    {
16 238
        if (self::$instance === null) {
17 1
            self::$instance = new self();
18
        }
19
20 238
        return self::$instance;
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::instance could return the type null which is incompatible with the type-hinted return Smoren\PartialIntersection\Util\NoValueMonad. Consider adding an additional type-check to rule them out.
Loading history...
21
    }
22
23 1
    private function __construct()
24
    {
25 1
    }
26
}
27