anonymous//src/DataStructure/Maybe/Maybe.php$1   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
cbo 1
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fundic\DataStructure\Maybe;
6
7
class Maybe
8
{
9
    private function __construct()
10
    {
11
    }
12
13
    final public static function nothing()
14
    {
15
        return new class() extends Maybe implements Nothing {};
16
    }
17
18
    final public static function just($value)
19
    {
20
        return new class($value) extends Maybe implements Just {
21
            private $value;
22
23
            public function __construct($value)
24
            {
25
                $this->value = $value;
26
            }
27
28
            public function get()
29
            {
30
                return $this->value;
31
            }
32
        };
33
    }
34
}
35