Code Duplication    Length = 8-11 lines in 2 locations

src/Util.php 2 locations

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