• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NexusPHP / framework / 14369703574

29 Mar 2025 05:15PM UTC coverage: 100.0%. Remained the same
14369703574

push

github

paulbalandan
Fix phpstan error

958 of 958 relevant lines covered (100.0%)

7.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Nexus/Option/None.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of the Nexus framework.
7
 *
8
 * (c) John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Nexus\Option;
15

16
/**
17
 * @implements Option<never>
18
 */
19
final readonly class None implements Option
20
{
21
    public function isSome(): bool
22
    {
23
        return false;
6✔
24
    }
25

26
    public function isSomeAnd(\Closure $predicate): bool
27
    {
28
        return false;
2✔
29
    }
30

31
    public function isNone(): bool
32
    {
33
        return true;
14✔
34
    }
35

36
    public function unwrap(): never
37
    {
38
        throw new NoneException();
2✔
39
    }
40

41
    /**
42
     * @template S
43
     *
44
     * @param S $default
45
     *
46
     * @return S
47
     */
48
    public function unwrapOr(mixed $default): mixed
49
    {
50
        return $default;
2✔
51
    }
52

53
    public function unwrapOrElse(\Closure $default): mixed
54
    {
55
        return $default();
2✔
56
    }
57

58
    public function map(\Closure $predicate): self
59
    {
60
        return $this;
2✔
61
    }
62

63
    /**
64
     * @template U
65
     * @template V
66
     *
67
     * @param V                    $default
68
     * @param (\Closure(never): U) $predicate
69
     *
70
     * @return V
71
     */
72
    public function mapOr(mixed $default, \Closure $predicate): mixed
73
    {
74
        return $default;
2✔
75
    }
76

77
    /**
78
     * @template U
79
     * @template V
80
     *
81
     * @param (\Closure(): V)      $default
82
     * @param (\Closure(never): U) $predicate
83
     *
84
     * @return V
85
     */
86
    public function mapOrElse(\Closure $default, \Closure $predicate): mixed
87
    {
88
        return $default();
2✔
89
    }
90

91
    public function and(Option $other): self
92
    {
93
        return $this;
2✔
94
    }
95

96
    public function andThen(\Closure $predicate): self
97
    {
98
        return $this;
2✔
99
    }
100

101
    public function filter(\Closure $predicate): self
102
    {
103
        return $this;
2✔
104
    }
105

106
    public function or(Option $other): Option
107
    {
108
        return $other;
2✔
109
    }
110

111
    public function orElse(\Closure $other): Option
112
    {
113
        return $other();
2✔
114
    }
115

116
    /**
117
     * @template S
118
     *
119
     * @param Option<S> $other
120
     *
121
     * @return ($other is Some<S> ? Some<S> : self<T>)
122
     */
123
    public function xor(Option $other): Option
124
    {
125
        return $other->isSome() ? $other : $this;
2✔
126
    }
127

128
    /**
129
     * @return \EmptyIterator
130
     */
131
    public function getIterator(): \Traversable
132
    {
133
        return new \EmptyIterator();
2✔
134
    }
135
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc