Code Duplication    Length = 8-11 lines in 2 locations

src/Util.php 2 locations

@@ 69-79 (lines=11) @@
66
     * @throws Exception if $valueToEnsure !== $valueToCheck
67
     * @throws InvalidArgumentException if $exception was not null, a string, or an Exception
68
     */
69
    public static function ensure($valueToEnsure, $valueToCheck, $exception = null, array $exceptionArgs = null)
70
    {
71
        if ($valueToEnsure !== $valueToCheck) {
72
            throw self::buildException(
73
                $exception ?: "'{$valueToEnsure}' did not equal '{$valueToCheck}'",
74
                $exceptionArgs
75
            );
76
        }
77
78
        return $valueToCheck;
79
    }
80
81
    /**
82
     * Ensures that $valueToThrowOn is not equal to $valueToCheck or it throws
@@ 103-110 (lines=8) @@
100
     * @throws Exception if $valueToThrowOn === $valueToCheck
101
     * @throws InvalidArgumentException if $exception was not null, a string, or an Exception
102
     */
103
    public static function ensureNot($valueToThrowOn, $valueToCheck, $exception = null, array $exceptionArgs = null)
104
    {
105
        if ($valueToThrowOn === $valueToCheck) {
106
            throw self::buildException($exception ?: "'{$valueToThrowOn}' equals '{$valueToCheck}'", $exceptionArgs);
107
        }
108
109
        return $valueToCheck;
110
    }
111
112
    /**
113
     * Helper method to return exception created from ensure[Not] call input.