Maybe   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$1 ➔ __construct() 0 4 1
A hp$1 ➔ get() 0 4 1
A __construct() 0 3 1
A nothing() 0 4 1
A just() 0 16 1
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