Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Simple::isValid() public #1519

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Rules/AlwaysInvalid.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class AlwaysInvalid extends Simple
{
public const TEMPLATE_SIMPLE = '__simple__';

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/AlwaysValid.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)]
final class AlwaysValid extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)]
final class ArrayType extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_array($input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/ArrayVal.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)]
final class ArrayVal extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_array($input) || $input instanceof ArrayAccess || $input instanceof SimpleXMLElement;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Base64.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)]
final class Base64 extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_string($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/BoolType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)]
final class BoolType extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_bool($input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/BoolVal.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)]
final class BoolVal extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_bool(filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE));
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Bsn.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)]
final class Bsn extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_scalar($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/CallableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)]
final class CallableType extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_callable($input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(callable $callback, mixed ...$arguments)
$this->arguments = $arguments;
}

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return (bool) call_user_func_array($this->callback, $this->getArguments($input));
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Cnh.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)]
final class Cnh extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_scalar($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Cnpj.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)]
final class Cnpj extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_scalar($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Core/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

abstract class Simple extends Standard
{
abstract protected function isValid(mixed $input): bool;
abstract public function isValid(mixed $input): bool;

public function evaluate(mixed $input): Result
{
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Countable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)]
final class Countable extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_array($input) || $input instanceof CountableInterface;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Cpf.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)]
final class Cpf extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
// Code ported from jsfromhell.com
$c = preg_replace('/\D/', '', $input);
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)]
final class Directory extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if ($input instanceof SplFileInfo) {
return $input->isDir();
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(?EmailValidator $validator = null)
$this->validator = $validator;
}

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_string($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Even.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)]
final class Even extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (filter_var($input, FILTER_VALIDATE_INT) === false) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Executable.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)]
final class Executable extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if ($input instanceof SplFileInfo) {
return $input->isExecutable();
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Exists.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)]
final class Exists extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if ($input instanceof SplFileInfo) {
$input = $input->getPathname();
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/FalseVal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)]
final class FalseVal extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return filter_var($input, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) === false;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Fibonacci.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)]
final class Fibonacci extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_numeric($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)]
final class File extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if ($input instanceof SplFileInfo) {
return $input->isFile();
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Finite.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)]
final class Finite extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_numeric($input) && is_finite((float) $input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/FloatType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)]
final class FloatType extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_float($input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/FloatVal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)]
final class FloatVal extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_float(filter_var($input, FILTER_VALIDATE_FLOAT));
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Hetu.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class Hetu extends Simple
{
use CanValidateDateTime;

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_string($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ final class Iban extends Simple
'VG' => 24,
];

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_string($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(?finfo $fileInfo = null)
$this->fileInfo = $fileInfo ?: new finfo(FILEINFO_MIME_TYPE);
}

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if ($input instanceof SplFileInfo) {
return $this->isValid($input->getPathname());
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Imei.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Imei extends Simple
{
private const IMEI_SIZE = 15;

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_scalar($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Infinite.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)]
final class Infinite extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_numeric($input) && is_infinite((float) $input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/IntType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)]
final class IntType extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_int($input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/IntVal.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)]
final class IntVal extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (is_int($input)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Isbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class Isbn extends Simple
'(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]$',
];

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_scalar($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/IterableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)]
final class IterableType extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return is_iterable($input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/IterableVal.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class IterableVal extends Simple
{
use CanValidateIterable;

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
return $this->isIterable($input);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)]
final class Json extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_string($input) || $input === '') {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/LeapDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
) {
}

protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if ($input instanceof DateTimeInterface) {
return $input->format('m-d') === '02-29';
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/LeapYear.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)]
final class LeapYear extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (is_numeric($input)) {
$date = strtotime(sprintf('%d-02-29', (int) $input));
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Lowercase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)]
final class Lowercase extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_string($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Luhn.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)]
final class Luhn extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!(new Digit())->evaluate($input)->isValid) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/MacAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)]
final class MacAddress extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_string($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/Negative.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)]
final class Negative extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (!is_numeric($input)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion library/Rules/NfeAccessKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)]
final class NfeAccessKey extends Simple
{
protected function isValid(mixed $input): bool
public function isValid(mixed $input): bool
{
if (mb_strlen($input) !== 44) {
return false;
Expand Down
Loading
Loading