| @@ 30-46 (lines=17) @@ | ||
| 27 | /** |
|
| 28 | * @package Limoncello\Validation |
|
| 29 | */ |
|
| 30 | final class IsArray extends ExecuteRule |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @param mixed $value |
|
| 34 | * @param ContextInterface $context |
|
| 35 | * |
|
| 36 | * @return array |
|
| 37 | * |
|
| 38 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
| 39 | */ |
|
| 40 | public static function execute($value, ContextInterface $context): array |
|
| 41 | { |
|
| 42 | return is_array($value) === true ? |
|
| 43 | static::createSuccessReply($value) : |
|
| 44 | static::createErrorReply($context, $value, ErrorCodes::IS_ARRAY, Messages::IS_ARRAY, []); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 30-46 (lines=17) @@ | ||
| 27 | /** |
|
| 28 | * @package Limoncello\Validation |
|
| 29 | */ |
|
| 30 | final class IsBool extends ExecuteRule |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @param mixed $value |
|
| 34 | * @param ContextInterface $context |
|
| 35 | * |
|
| 36 | * @return array |
|
| 37 | * |
|
| 38 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
| 39 | */ |
|
| 40 | public static function execute($value, ContextInterface $context): array |
|
| 41 | { |
|
| 42 | return is_bool($value) === true ? |
|
| 43 | static::createSuccessReply($value) : |
|
| 44 | static::createErrorReply($context, $value, ErrorCodes::IS_BOOL, Messages::IS_BOOL, []); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 30-46 (lines=17) @@ | ||
| 27 | /** |
|
| 28 | * @package Limoncello\Validation |
|
| 29 | */ |
|
| 30 | final class IsDateTime extends ExecuteRule |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @param mixed $value |
|
| 34 | * @param ContextInterface $context |
|
| 35 | * |
|
| 36 | * @return array |
|
| 37 | * |
|
| 38 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
| 39 | */ |
|
| 40 | public static function execute($value, ContextInterface $context): array |
|
| 41 | { |
|
| 42 | return $value instanceof DateTimeInterface ? |
|
| 43 | static::createSuccessReply($value) : |
|
| 44 | static::createErrorReply($context, $value, ErrorCodes::IS_DATE_TIME, Messages::IS_DATE_TIME, []); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 30-46 (lines=17) @@ | ||
| 27 | /** |
|
| 28 | * @package Limoncello\Validation |
|
| 29 | */ |
|
| 30 | final class IsFloat extends ExecuteRule |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @param mixed $value |
|
| 34 | * @param ContextInterface $context |
|
| 35 | * |
|
| 36 | * @return array |
|
| 37 | * |
|
| 38 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
| 39 | */ |
|
| 40 | public static function execute($value, ContextInterface $context): array |
|
| 41 | { |
|
| 42 | return is_float($value) === true ? |
|
| 43 | static::createSuccessReply($value) : |
|
| 44 | static::createErrorReply($context, $value, ErrorCodes::IS_FLOAT, Messages::IS_FLOAT, []); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 30-46 (lines=17) @@ | ||
| 27 | /** |
|
| 28 | * @package Limoncello\Validation |
|
| 29 | */ |
|
| 30 | final class IsInt extends ExecuteRule |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @param mixed $value |
|
| 34 | * @param ContextInterface $context |
|
| 35 | * |
|
| 36 | * @return array |
|
| 37 | * |
|
| 38 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
| 39 | */ |
|
| 40 | public static function execute($value, ContextInterface $context): array |
|
| 41 | { |
|
| 42 | return is_int($value) === true ? |
|
| 43 | static::createSuccessReply($value) : |
|
| 44 | static::createErrorReply($context, $value, ErrorCodes::IS_INT, Messages::IS_INT, []); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 30-46 (lines=17) @@ | ||
| 27 | /** |
|
| 28 | * @package Limoncello\Validation |
|
| 29 | */ |
|
| 30 | final class IsNumeric extends ExecuteRule |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @param mixed $value |
|
| 34 | * @param ContextInterface $context |
|
| 35 | * |
|
| 36 | * @return array |
|
| 37 | * |
|
| 38 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
| 39 | */ |
|
| 40 | public static function execute($value, ContextInterface $context): array |
|
| 41 | { |
|
| 42 | return is_numeric($value) === true ? |
|
| 43 | static::createSuccessReply($value) : |
|
| 44 | static::createErrorReply($context, $value, ErrorCodes::IS_NUMERIC, Messages::IS_NUMERIC, []); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 30-46 (lines=17) @@ | ||
| 27 | /** |
|
| 28 | * @package Limoncello\Validation |
|
| 29 | */ |
|
| 30 | final class IsString extends ExecuteRule |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @param mixed $value |
|
| 34 | * @param ContextInterface $context |
|
| 35 | * |
|
| 36 | * @return array |
|
| 37 | * |
|
| 38 | * @SuppressWarnings(PHPMD.StaticAccess) |
|
| 39 | */ |
|
| 40 | public static function execute($value, ContextInterface $context): array |
|
| 41 | { |
|
| 42 | return is_string($value) === true ? |
|
| 43 | static::createSuccessReply($value) : |
|
| 44 | static::createErrorReply($context, $value, ErrorCodes::IS_STRING, Messages::IS_STRING, []); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||