-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListOfErrors.php
More file actions
69 lines (59 loc) · 1.59 KB
/
ListOfErrors.php
File metadata and controls
69 lines (59 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
* Copyright 2025 Cloud Creativity Limited
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
declare(strict_types=1);
namespace CloudCreativity\Modules\Contracts\Toolkit\Result;
use Closure;
use CloudCreativity\Modules\Contracts\Toolkit\Iterables\ListIterator;
use UnitEnum;
/**
* @extends ListIterator<Error>
*/
interface ListOfErrors extends ListIterator
{
/**
* Get the first error in the list, or the first matching error.
*
* @param Closure(Error): bool|UnitEnum|null $matcher
* @return Error|null
*/
public function first(Closure|UnitEnum|null $matcher = null): ?Error;
/**
* Does the list contain a matching error?
*
* @param Closure(Error): bool|UnitEnum $matcher
* @return bool
*/
public function contains(Closure|UnitEnum $matcher): bool;
/**
* Get all the unique error codes in the list.
*
* @return array<UnitEnum>
*/
public function codes(): array;
/**
* Get the first error code in the list.
*
* @return UnitEnum|null
*/
public function code(): ?UnitEnum;
/**
* Return a new instance with the provided error pushed on to the end of the list.
*
* @param Error $error
* @return static
*/
public function push(Error $error): self;
/**
* Return a new instance with the provided errors merged in.
*
* @param ListOfErrors $other
* @return static
*/
public function merge(ListOfErrors $other): self;
}