Skip to content

Commit

Permalink
Removed named params
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaplet committed Apr 22, 2024
1 parent 9d99fd5 commit ea8d4b1
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Collection/WriteBuilder/Rule/AnyOfRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(
protected ?string $message = null
)
{
parent::__construct(message: $message);
parent::__construct($message);
}

public function message(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/WriteBuilder/Rule/CallableRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CallableRule extends BaseRule
protected array $callback;

public function __construct(
callable $callback,
callable $callback,
protected ?string $message = null,
)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/WriteBuilder/Rule/EqualRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
protected ?string $message = null
)
{
parent::__construct(message: $message);
parent::__construct($message);
}

public function message(): string
Expand Down
16 changes: 3 additions & 13 deletions src/Collection/WriteBuilder/Rule/HourMinuteRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@

class HourMinuteRule extends BaseRule
{
public function __construct(
protected ?string $message = null,
protected bool $normalize = true
)
{
parent::__construct(message: $message);
}

public function message(): string
{
return $this->message ?: "Field must be a valid hour and minute in ISO format. Example: 07:00";
Expand All @@ -39,11 +31,9 @@ public function validate(): bool
$date = \DateTime::createFromFormat('H:i', $value);

if ($date instanceof \DateTime) {
if ($this->normalize) {
$date->setDate(1970, 1, 1);
$date->setTime((int)$date->format('H'), (int)$date->format('i'));
$this->field->setValue($date->format('Y-m-d H:i:s'));
}
$date->setDate(1970, 1, 1);
$date->setTime((int)$date->format('H'), (int)$date->format('i'));
$this->field->setValue($date->format('Y-m-d H:i:s'));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Collection/WriteBuilder/Rule/MinRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
protected ?string $message = null
)
{
parent::__construct(message: $message);
parent::__construct($message);
}

public function message(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/WriteBuilder/Rule/PhoneCzRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
protected bool $normalize = true
)
{
parent::__construct(message: $message);
parent::__construct($message);
}

public function message(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/WriteBuilder/Rule/RegexRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
protected ?string $message = null
)
{
parent::__construct(message: $message);
parent::__construct($message);
}

public function message(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/WriteBuilder/Rule/UniqueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
protected ?string $message = null
)
{
parent::__construct(message: $message);
parent::__construct($message);
}

public function message(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/WriteBuilder/Rule/VideoLinkRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
protected bool $normalize = true
)
{
parent::__construct(message: $message);
parent::__construct($message);
}

public function message(): string
Expand Down

0 comments on commit ea8d4b1

Please sign in to comment.