GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Maybe   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 119
rs 10
wmc 11

10 Methods

Rating   Name   Duplication   Size   Complexity  
A flatMap() 0 3 1
A otherwise() 0 3 1
A all() 0 3 1
A map() 0 3 1
A of() 0 7 2
A just() 0 3 1
A __construct() 0 3 1
A filter() 0 3 1
A match() 0 3 1
A nothing() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Immutable;
5
6
use Innmind\Immutable\Maybe\{
7
    Implementation,
8
    Just,
9
    Nothing,
10
};
11
12
/**
13
 * @template T
14
 * @psalm-immutable
15
 */
16
final class Maybe
17
{
18
    /** @var Implementation<T> */
19
    private Implementation $maybe;
20
21
    /**
22
     * @param Implementation<T> $maybe
23
     */
24
    private function __construct(Implementation $maybe)
25
    {
26
        $this->maybe = $maybe;
27
    }
28
29
    /**
30
     * @template V
31
     * @psalm-pure
32
     *
33
     * @param V $value
0 ignored issues
show
Bug introduced by
The type Innmind\Immutable\V was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
     *
35
     * @return self<V>
36
     */
37
    public static function just($value): self
38
    {
39
        return new self(new Just($value));
40
    }
41
42
    /**
43
     * @psalm-pure
44
     */
45
    public static function nothing(): self
46
    {
47
        return new self(new Nothing);
48
    }
49
50
    /**
51
     * @template V
52
     * @psalm-pure
53
     *
54
     * @param V|null $value
55
     *
56
     * @return self<V>
57
     */
58
    public static function of($value): self
59
    {
60
        if (\is_null($value)) {
61
            return self::nothing();
62
        }
63
64
        return self::just($value);
65
    }
66
67
    /**
68
     * The comprehension is called only when all values exist
69
     *
70
     * @psalm-pure
71
     * @no-named-arguments
72
     */
73
    public static function all(self $first, self ...$rest): Maybe\Comprehension
74
    {
75
        return Maybe\Comprehension::of($first, ...$rest);
76
    }
77
78
    /**
79
     * @template V
80
     *
81
     * @param callable(T): V $map
82
     *
83
     * @return self<V>
84
     */
85
    public function map(callable $map): self
86
    {
87
        return new self($this->maybe->map($map));
88
    }
89
90
    /**
91
     * @template V
92
     *
93
     * @param callable(T): Maybe<V> $map
94
     *
95
     * @return Maybe<V>
96
     */
97
    public function flatMap(callable $map): self
98
    {
99
        return $this->maybe->flatMap($map);
100
    }
101
102
    /**
103
     * @template V
104
     *
105
     * @param callable(T): V $just
106
     * @param callable(): V $nothing
107
     *
108
     * @return V
109
     */
110
    public function match(callable $just, callable $nothing)
111
    {
112
        return $this->maybe->match($just, $nothing);
113
    }
114
115
    /**
116
     * @template V
117
     *
118
     * @param callable(): Maybe<V> $otherwise
119
     *
120
     * @return Maybe<T|V>
121
     */
122
    public function otherwise(callable $otherwise): self
123
    {
124
        return $this->maybe->otherwise($otherwise);
125
    }
126
127
    /**
128
     * @param callable(T): bool $predicate
129
     *
130
     * @return self<T>
131
     */
132
    public function filter(callable $predicate): self
133
    {
134
        return new self($this->maybe->filter($predicate));
135
    }
136
}
137