-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathhelpers.php
More file actions
44 lines (40 loc) · 710 Bytes
/
helpers.php
File metadata and controls
44 lines (40 loc) · 710 Bytes
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
<?php
use Prewk\Result\Err;
use Prewk\Result\Ok;
/**
* Procedural style construction of Result instances
*
* @author Oskar Thornblad
*/
if (! function_exists('ok')) {
/**
* Represent a successful result
*
* @codeCoverageIgnore
*
* @template T
*
* @param T $value
* @return \Prewk\Result\Ok<T>
*/
function ok($value = null): Ok
{
return new Ok($value);
}
}
if (! function_exists('err')) {
/**
* Represent a failed result
*
* @codeCoverageIgnore
*
* @template E
*
* @param E $err
* @return \Prewk\Result\Err<E>
*/
function err($err): Err
{
return new Err($err);
}
}