Error.php
1.35 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
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace Dotenv\Regex;
use PhpOption\None;
use PhpOption\Some;
class Error extends Result
{
/**
* @var string
*/
private $value;
/**
* Internal constructor for an error value.
*
* @param string $value
*
* @return void
*/
private function __construct($value)
{
$this->value = $value;
}
/**
* Create a new error value.
*
* @param string $value
*
* @return \Dotenv\Regex\Result
*/
public static function create($value)
{
return new self($value);
}
/**
* Get the success option value.
*
* @return \PhpOption\Option
*/
public function success()
{
return None::create();
}
/**
* Map over the success value.
*
* @param callable $f
*
* @return \Dotenv\Regex\Result
*/
public function mapSuccess(callable $f)
{
return self::create($this->value);
}
/**
* Get the error option value.
*
* @return \PhpOption\Option
*/
public function error()
{
return Some::create($this->value);
}
/**
* Map over the error value.
*
* @param callable $f
*
* @return \Dotenv\Regex\Result
*/
public function mapError(callable $f)
{
return self::create($f($this->value));
}
}