Skip to content

Commit

Permalink
feat: add default value (#5)
Browse files Browse the repository at this point in the history
* feat: add default value

* style: formatting
  • Loading branch information
64knl authored Oct 19, 2023
1 parent 1e83427 commit ce25677
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/NotFound/Layout/Inputs/AbstractInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ public function setValue(mixed $value): self
return $this;
}

public function setDefaultValue(mixed $defaultValue): self
{
if (! is_string($defaultValue)) {
$this->abortLogSetValueError('AbstractInput', 'string', $defaultValue);
}
$this->properties->defaultValue = $defaultValue;

return $this;
}

protected function abortLogSetValueError(string $class, string $requiredType, mixed $newValue): void
{
$message = sprintf(
Expand Down
10 changes: 10 additions & 0 deletions src/NotFound/Layout/Inputs/LayoutInputSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ public function setMax(int $max): self

return $this;
}

public function setDefaultValue(mixed $defaultValue): self
{
if (! is_int($defaultValue)) {
$this->abortLogSetValueError('InputSlider', 'integer', $defaultValue);
}
$this->properties->defaultValue = $defaultValue;

return $this;
}
}

0 comments on commit ce25677

Please sign in to comment.