Result   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ __construct() 0 4 1
A hp$0 ➔ get() 0 4 1
A hp$2 ➔ __construct() 0 4 1
A hp$2 ➔ inner() 0 4 1
A __construct() 0 3 1
A just() 0 16 1
A notFound() 0 4 1
A exception() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fundic\DataStructure\Result;
6
7
class Result
8
{
9
    private function __construct()
10
    {
11
    }
12
13
    final public static function just($value)
14
    {
15
        return new class($value) extends Result implements Just {
16
            private $value;
17
18
            public function __construct($value)
19
            {
20
                $this->value = $value;
21
            }
22
23
            public function get()
24
            {
25
                return $this->value;
26
            }
27
        };
28
    }
29
30
    final public static function notFound()
31
    {
32
        return new class() extends Result implements NotFound {};
33
    }
34
35
    final public static function exception(\Throwable $exception)
36
    {
37
        return new class($exception) extends Result implements Exception {
38
            private $exception;
39
40
            public function __construct(\Throwable $exception)
41
            {
42
                $this->exception = $exception;
43
            }
44
45
            public function inner() : \Throwable
46
            {
47
                return $this->exception;
48
            }
49
        };
50
    }
51
}
52