Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit fe90a1e

Browse files
committed
chore: some refactoring
1 parent a6d6533 commit fe90a1e

3 files changed

Lines changed: 5 additions & 18 deletions

File tree

src/Exception/ValidationException.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@
44

55
class ValidationException extends \Exception
66
{
7-
8-
/**
9-
* @throws \Exception
10-
*/
117
public function __construct(string $message, array $parameters = [])
128
{
139
$message = $this->formatMessage($message, $parameters);
1410
parent::__construct($message);
1511
}
1612

17-
/**
18-
* @throws \Exception
19-
*/
2013
private function formatMessage(string $message, array $parameters = []): string
2114
{
2215
foreach ($parameters as $parameter => $value) {
@@ -26,9 +19,6 @@ private function formatMessage(string $message, array $parameters = []): string
2619
return $message;
2720
}
2821

29-
/**
30-
* @throws \Exception
31-
*/
3222
private function formatValue(mixed $value): string
3323
{
3424
if ($value instanceof \DateTimeInterface) {
@@ -70,9 +60,6 @@ private function formatValue(mixed $value): string
7060
return (string) $value;
7161
}
7262

73-
/**
74-
* @throws \Exception
75-
*/
7663
private function formatValues(array $values): string
7764
{
7865
foreach ($values as $key => $value) {

src/Rule/AbstractRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class AbstractRule
66
{
7-
private string $name = '';
7+
private string $name;
88

99
public function getName(): string
1010
{

src/Validator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function __callStatic(string $ruleName, array $arguments = []): se
3737
public function __call(string $ruleName, array $arguments = []): self
3838
{
3939
$factory = new Factory();
40-
$this->addRule($ruleName, $factory->createRule($ruleName, $arguments));
40+
$this->addRule($factory->createRule($ruleName, $arguments));
4141

4242
return $this;
4343
}
@@ -55,7 +55,7 @@ public function assert(mixed $input, string $name): void
5555
public function validate(mixed $input): bool
5656
{
5757
try {
58-
$this->assert($input, '');
58+
$this->assert($input, 'null');
5959
}
6060
catch (ValidationException) {
6161
return false;
@@ -72,9 +72,9 @@ private function getRules(): array
7272
return $this->rules;
7373
}
7474

75-
private function addRule(string $name, RuleInterface $rule): self
75+
private function addRule(RuleInterface $rule): self
7676
{
77-
$this->rules[$name] = $rule;
77+
$this->rules[] = $rule;
7878

7979
return $this;
8080
}

0 commit comments

Comments
 (0)