public static function forKey($key, Exception $cause = null)
    {
        return new static(sprintf(
            'Expected a key of type integer or string. Got: %s',
            is_object($key) ? get_class($key) : gettype($key)
        ), 0, $cause);
    }
public static function forKey($key, Exception $cause = null)
    {
        return new static(sprintf(
            'Expected a key of type integer or string. Got: %s',
            is_object($key) ? get_class($key) : gettype($key)
        ), 0, $cause);
    }
public static function forKey ( $ key , Exception $ cause = null ) { return new static ( sprintf ( 'Expected a key of type integer or string. Got: %s' , is_object ( $ key ) ? get_class ( $ key ) : gettype ( $ key ) ) , 0 , $ cause ) ; }
Creates an exception for an invalid key.

@param mixed          $key   The invalid key.
@param Exception|null $cause The exception that caused this exception.

@return static The created exception.
Creates an exception for an invalid key .