Skip to content

Commit c77c762

Browse files
committed
refactor: code refactor
1 parent c3f6a9a commit c77c762

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

src/ErrorBag.php

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,8 @@ public function addError($role, $customMessages)
2727
$message = $this->replacePlaceholders($placeholders, $role->message());
2828
}
2929

30-
$nestedKeys = explode('.', $attributeKey);
30+
$this->errors[$attributeKey][] = $message;
3131

32-
if (is_array($nestedKeys)) {
33-
$this->generateNestedError($nestedKeys, $message);
34-
} else {
35-
$this->errors[$attributeKey][] = $message;
36-
}
37-
38-
}
39-
40-
private function generateNestedError($keys, $message)
41-
{
42-
$errors = &$this->errors;
43-
44-
while ($keys) {
45-
$key = array_shift($keys);
46-
47-
if (isset($current[$key]) && !is_array($current[$key])) {
48-
$errors[$key] = [];
49-
}
50-
51-
$errors = &$errors[$key];
52-
}
53-
54-
$errors = $message;
5532
}
5633

5734
private function replacePlaceholders($placeholders, $message)

0 commit comments

Comments
 (0)