1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the eav package. |
4
|
|
|
* |
5
|
|
|
* @author Alex Kuperwood <[email protected]> |
6
|
|
|
* @copyright 2025 Alex Kuperwood |
7
|
|
|
* @license https://opensource.org/license/mit The MIT License |
8
|
|
|
*/ |
9
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace Kuperwood\Eav\Result; |
12
|
|
|
|
13
|
|
|
use Kuperwood\Eav\Enum\_RESULT; |
14
|
|
|
|
15
|
|
|
class Result |
16
|
|
|
{ |
17
|
|
|
private int $code; |
18
|
|
|
private string $message; |
19
|
|
|
|
20
|
|
|
private $data = null; |
21
|
|
|
|
22
|
1 |
|
public function getCode(): int |
23
|
|
|
{ |
24
|
1 |
|
return $this->code; |
25
|
|
|
} |
26
|
|
|
|
27
|
1 |
|
public function setCode(int $code): self |
28
|
|
|
{ |
29
|
1 |
|
$this->code = $code; |
30
|
|
|
|
31
|
1 |
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
1 |
|
public function getMessage(): string |
35
|
|
|
{ |
36
|
1 |
|
return $this->message; |
37
|
|
|
} |
38
|
|
|
|
39
|
1 |
|
public function setMessage(string $message): self |
40
|
|
|
{ |
41
|
1 |
|
$this->message = $message; |
42
|
|
|
|
43
|
1 |
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
1 |
|
public function getData() |
47
|
|
|
{ |
48
|
1 |
|
return $this->data; |
49
|
|
|
} |
50
|
|
|
|
51
|
1 |
|
public function setData($data): self |
52
|
|
|
{ |
53
|
1 |
|
$this->data = $data; |
54
|
|
|
|
55
|
1 |
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
1 |
|
public function created(): self |
59
|
|
|
{ |
60
|
1 |
|
return $this->setCode(_RESULT::CREATED) |
61
|
1 |
|
->setMessage(_RESULT::message(_RESULT::CREATED)); |
62
|
|
|
} |
63
|
|
|
|
64
|
1 |
|
public function updated(): self |
65
|
|
|
{ |
66
|
1 |
|
return $this->setCode(_RESULT::UPDATED) |
67
|
1 |
|
->setMessage(_RESULT::message(_RESULT::UPDATED)); |
68
|
|
|
} |
69
|
|
|
|
70
|
1 |
|
public function deleted(): self |
71
|
|
|
{ |
72
|
1 |
|
return $this->setCode(_RESULT::DELETED) |
73
|
1 |
|
->setMessage(_RESULT::message(_RESULT::DELETED)); |
74
|
|
|
} |
75
|
|
|
|
76
|
1 |
|
public function notDeleted(): self |
77
|
|
|
{ |
78
|
1 |
|
return $this->setCode(_RESULT::NOT_DELETED) |
79
|
1 |
|
->setMessage(_RESULT::message(_RESULT::NOT_DELETED)); |
80
|
|
|
} |
81
|
|
|
|
82
|
1 |
|
public function found(): self |
83
|
|
|
{ |
84
|
1 |
|
return $this->setCode(_RESULT::FOUND) |
85
|
1 |
|
->setMessage(_RESULT::message(_RESULT::FOUND)); |
86
|
|
|
} |
87
|
|
|
|
88
|
1 |
|
public function notFound(): self |
89
|
|
|
{ |
90
|
1 |
|
return $this->setCode(_RESULT::NOT_FOUND) |
91
|
1 |
|
->setMessage(_RESULT::message(_RESULT::NOT_FOUND)); |
92
|
|
|
} |
93
|
|
|
|
94
|
1 |
|
public function notEnoughArgs(): self |
95
|
|
|
{ |
96
|
1 |
|
return $this->setCode(_RESULT::NOT_ENOUGH_ARGS) |
97
|
1 |
|
->setMessage(_RESULT::message(_RESULT::NOT_ENOUGH_ARGS)); |
98
|
|
|
} |
99
|
|
|
|
100
|
1 |
|
public function notAllowed(): self |
101
|
|
|
{ |
102
|
1 |
|
return $this->setCode(_RESULT::NOT_ALLOWED) |
103
|
1 |
|
->setMessage(_RESULT::message(_RESULT::NOT_ALLOWED)); |
104
|
|
|
} |
105
|
|
|
|
106
|
1 |
|
public function empty(): self |
107
|
|
|
{ |
108
|
1 |
|
return $this->setCode(_RESULT::EMPTY) |
109
|
1 |
|
->setMessage(_RESULT::message(_RESULT::EMPTY)); |
110
|
|
|
} |
111
|
|
|
|
112
|
1 |
|
public function validationFails(): self |
113
|
|
|
{ |
114
|
1 |
|
return $this->setCode(_RESULT::VALIDATION_FAILS) |
115
|
1 |
|
->setMessage(_RESULT::message(_RESULT::VALIDATION_FAILS)); |
116
|
|
|
} |
117
|
|
|
|
118
|
1 |
|
public function validationPassed(): self |
119
|
|
|
{ |
120
|
1 |
|
return $this->setCode(_RESULT::VALIDATION_PASSED) |
121
|
1 |
|
->setMessage(_RESULT::message(_RESULT::VALIDATION_PASSED)); |
122
|
|
|
} |
123
|
|
|
|
124
|
1 |
|
public function exportSuccess(): self |
125
|
|
|
{ |
126
|
1 |
|
return $this->setCode(_RESULT::EXPORT_SUCCESS) |
127
|
1 |
|
->setMessage(_RESULT::message(_RESULT::EXPORT_SUCCESS)); |
128
|
|
|
} |
129
|
|
|
|
130
|
1 |
|
public function exportFailed(): self |
131
|
|
|
{ |
132
|
1 |
|
return $this->setCode(_RESULT::EXPORT_FAILED) |
133
|
1 |
|
->setMessage(_RESULT::message(_RESULT::EXPORT_FAILED)); |
134
|
|
|
} |
135
|
|
|
|
136
|
1 |
|
public function importSuccess(): self |
137
|
|
|
{ |
138
|
1 |
|
return $this->setCode(_RESULT::IMPORT_SUCCESS) |
139
|
1 |
|
->setMessage(_RESULT::message(_RESULT::IMPORT_SUCCESS)); |
140
|
|
|
} |
141
|
|
|
|
142
|
1 |
|
public function importFailed(): self |
143
|
|
|
{ |
144
|
1 |
|
return $this->setCode(_RESULT::IMPORT_FAILED) |
145
|
1 |
|
->setMessage(_RESULT::message(_RESULT::IMPORT_FAILED)); |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
|