Maybe::just()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Maybe.php$1 ➔ __construct() 0 4 1
A Maybe.php$1 ➔ get() 0 4 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