Code Duplication    Length = 17-17 lines in 6 locations

src/Rules/Types/AsArray.php 1 location

@@ 26-42 (lines=17) @@
23
/**
24
 * @package Limoncello\Validation
25
 */
26
final class AsArray extends ExecuteRule
27
{
28
    /**
29
     * @param mixed            $value
30
     * @param ContextInterface $context
31
     *
32
     * @return array
33
     *
34
     * @SuppressWarnings(PHPMD.StaticAccess)
35
     */
36
    public static function execute($value, ContextInterface $context): array
37
    {
38
        return is_array($value) === true ?
39
            static::createSuccessReply($value) :
40
            static::createErrorReply($context, $value, ErrorCodes::IS_ARRAY);
41
    }
42
}
43

src/Rules/Types/AsBool.php 1 location

@@ 26-42 (lines=17) @@
23
/**
24
 * @package Limoncello\Validation
25
 */
26
final class AsBool extends ExecuteRule
27
{
28
    /**
29
     * @param mixed            $value
30
     * @param ContextInterface $context
31
     *
32
     * @return array
33
     *
34
     * @SuppressWarnings(PHPMD.StaticAccess)
35
     */
36
    public static function execute($value, ContextInterface $context): array
37
    {
38
        return is_bool($value) === true ?
39
            static::createSuccessReply($value) :
40
            static::createErrorReply($context, $value, ErrorCodes::IS_BOOL);
41
    }
42
}
43

src/Rules/Types/AsFloat.php 1 location

@@ 26-42 (lines=17) @@
23
/**
24
 * @package Limoncello\Validation
25
 */
26
final class AsFloat extends ExecuteRule
27
{
28
    /**
29
     * @param mixed            $value
30
     * @param ContextInterface $context
31
     *
32
     * @return array
33
     *
34
     * @SuppressWarnings(PHPMD.StaticAccess)
35
     */
36
    public static function execute($value, ContextInterface $context): array
37
    {
38
        return is_float($value) === true ?
39
            static::createSuccessReply($value) :
40
            static::createErrorReply($context, $value, ErrorCodes::IS_FLOAT);
41
    }
42
}
43

src/Rules/Types/AsInt.php 1 location

@@ 26-42 (lines=17) @@
23
/**
24
 * @package Limoncello\Validation
25
 */
26
final class AsInt extends ExecuteRule
27
{
28
    /**
29
     * @param mixed            $value
30
     * @param ContextInterface $context
31
     *
32
     * @return array
33
     *
34
     * @SuppressWarnings(PHPMD.StaticAccess)
35
     */
36
    public static function execute($value, ContextInterface $context): array
37
    {
38
        return is_int($value) === true ?
39
            static::createSuccessReply($value) :
40
            static::createErrorReply($context, $value, ErrorCodes::IS_INT);
41
    }
42
}
43

src/Rules/Types/AsNumeric.php 1 location

@@ 26-42 (lines=17) @@
23
/**
24
 * @package Limoncello\Validation
25
 */
26
final class AsNumeric extends ExecuteRule
27
{
28
    /**
29
     * @param mixed            $value
30
     * @param ContextInterface $context
31
     *
32
     * @return array
33
     *
34
     * @SuppressWarnings(PHPMD.StaticAccess)
35
     */
36
    public static function execute($value, ContextInterface $context): array
37
    {
38
        return is_numeric($value) === true ?
39
            static::createSuccessReply($value) :
40
            static::createErrorReply($context, $value, ErrorCodes::IS_NUMERIC);
41
    }
42
}
43

src/Rules/Types/AsString.php 1 location

@@ 26-42 (lines=17) @@
23
/**
24
 * @package Limoncello\Validation
25
 */
26
final class AsString extends ExecuteRule
27
{
28
    /**
29
     * @param mixed            $value
30
     * @param ContextInterface $context
31
     *
32
     * @return array
33
     *
34
     * @SuppressWarnings(PHPMD.StaticAccess)
35
     */
36
    public static function execute($value, ContextInterface $context): array
37
    {
38
        return is_string($value) === true ?
39
            static::createSuccessReply($value) :
40
            static::createErrorReply($context, $value, ErrorCodes::IS_STRING);
41
    }
42
}
43