-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorWarning.php
More file actions
126 lines (97 loc) · 2.65 KB
/
Copy pathErrorWarning.php
File metadata and controls
126 lines (97 loc) · 2.65 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
declare(strict_types=1);
namespace Rancoud\Model;
class ErrorWarning
{
protected array $errorMessage = [];
protected array $errorFields = [];
protected array $warningMessage = [];
protected array $warningFields = [];
public function getErrorMessages(): array
{
return $this->errorMessage;
}
public function hasErrorMessages(): bool
{
return \count($this->errorMessage) > 0;
}
protected function addErrorMessage(string $error): void
{
$this->errorMessage[] = $error;
}
protected function resetErrorMessage(): void
{
$this->errorMessage = [];
}
public function getErrorFields(): array
{
return $this->errorFields;
}
public function hasErrorFields(): bool
{
return \count($this->errorFields) > 0;
}
protected function addErrorField(string $field, string $reasons): void
{
if (!isset($this->errorFields[$field])) {
$this->errorFields[$field] = [];
}
$this->errorFields[$field][] = $reasons;
}
protected function resetErrorField(?string $field = null): void
{
if ($field === null) {
$this->errorFields = [];
return;
}
if (\array_key_exists($field, $this->errorFields)) {
unset($this->errorFields[$field]);
}
}
public function getWarningMessages(): array
{
return $this->warningMessage;
}
public function hasWarningMessages(): bool
{
return \count($this->warningMessage) > 0;
}
protected function addWarningMessage(string $warning): void
{
$this->warningMessage[] = $warning;
}
protected function resetWarningMessage(): void
{
$this->warningMessage = [];
}
public function getWarningFields(): array
{
return $this->warningFields;
}
public function hasWarningFields(): bool
{
return \count($this->warningFields) > 0;
}
protected function addWarningField(string $field, string $reasons): void
{
if (!isset($this->warningFields[$field])) {
$this->warningFields[$field] = [];
}
$this->warningFields[$field][] = $reasons;
}
protected function resetWarningField(?string $field = null): void
{
if ($field === null) {
$this->warningFields = [];
return;
}
if (\array_key_exists($field, $this->warningFields)) {
unset($this->warningFields[$field]);
}
}
protected function resetAllErrors(): void
{
$this->resetErrorField();
$this->resetErrorMessage();
}
}