Code Duplication    Length = 25-25 lines in 2 locations

src/IncomparableException.php 1 location

@@ 22-46 (lines=25) @@
19
 *
20
 * @author Marcos Passos <[email protected]>
21
 */
22
class IncomparableException extends InvalidArgumentException
23
{
24
    /**
25
     * Creates a new exception for the given value type.
26
     *
27
     * @param string         $type  The name of the expected type.
28
     * @param mixed          $value The specified value.
29
     * @param int            $code  The exception code.
30
     * @param Exception|null $cause The exception that caused this exception.
31
     *
32
     * @return UnexpectedTypeException The new exception.
33
     */
34
    public static function forType($type, $value, $code = 0, Exception $cause = null)
35
    {
36
        return new self(
37
            sprintf(
38
                'Unable to compare "%s" with "%s".',
39
                $type,
40
                is_object($value) ? get_class($value) : gettype($value)
41
            ),
42
            $code,
43
            $cause
44
        );
45
    }
46
}
47

src/UnexpectedTypeException.php 1 location

@@ 22-46 (lines=25) @@
19
 *
20
 * @author Marcos Passos <[email protected]>
21
 */
22
class UnexpectedTypeException extends InvalidArgumentException
23
{
24
    /**
25
     * Creates a new exception for the given value type.
26
     *
27
     * @param string         $type  The name of the expected type.
28
     * @param mixed          $value The specified value.
29
     * @param int            $code  The exception code.
30
     * @param Exception|null $cause The exception that caused this exception.
31
     *
32
     * @return UnexpectedTypeException The new exception.
33
     */
34
    public static function forType($type, $value, $code = 0, Exception $cause = null)
35
    {
36
        return new self(
37
            sprintf(
38
                'Expected value of type "%s", given "%s".',
39
                $type,
40
                is_object($value) ? get_class($value) : gettype($value)
41
            ),
42
            $code,
43
            $cause
44
        );
45
    }
46
}
47