public static function castFrom($value, string $name = 'Uri'): self
    {
        if ($value instanceof self) {
            return $value;
        }

        if (is_string($value)) {
            return self::fromString($value);
        }

        throw new \InvalidArgumentException(
                $name . ' must be a string containing a HTTP URI or an instance of '
                . get_class() . ', but was '
                . (is_object($value) ? get_class($value) : gettype($value))
        );
    }
public static function castFrom($value, string $name = 'Uri'): self
    {
        if ($value instanceof self) {
            return $value;
        }

        if (is_string($value)) {
            return self::fromString($value);
        }

        throw new \InvalidArgumentException(
                $name . ' must be a string containing a HTTP URI or an instance of '
                . get_class() . ', but was '
                . (is_object($value) ? get_class($value) : gettype($value))
        );
    }
public static function castFrom ( $ value , string $ name = 'Uri' ) : self { if ( $ value instanceof self ) { return $ value ; } if ( is_string ( $ value ) ) { return self :: fromString ( $ value ) ; } throw new \ InvalidArgumentException ( $ name . ' must be a string containing a HTTP URI or an instance of ' . get_class ( ) . ', but was ' . ( is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ value ) ) ) ; }
casts given value to an instance of HttpUri

@param   string|\stubbles\peer\http\HttpUri  $value  value to cast to HttpUri
@param   string                              $name   optional  name of parameter to cast from
@return  \stubbles\peer\http\HttpUri
@throws  \InvalidArgumentException
@since   4.0.0
casts given value to an instance of HttpUri