src/Micrometa/Domain/Factory/IriFactory.php
public static function create($iri)
    {
        // Cast as item type object if only a string is given
        if (is_string($iri)) {
            $iri = (object)['profile' => '', 'name' => $iri];
        }

        // If the IRI is invalid
        if (!self::validateIriStructure($iri)) {
            throw new InvalidArgumentException(
                InvalidArgumentException::INVALID_IRI_STR,
                InvalidArgumentException::INVALID_IRI
            );
        }

        return new Iri($iri->profile, $iri->name);
    }
public static function create($iri)
    {
        // Cast as item type object if only a string is given
        if (is_string($iri)) {
            $iri = (object)['profile' => '', 'name' => $iri];
        }

        // If the IRI is invalid
        if (!self::validateIriStructure($iri)) {
            throw new InvalidArgumentException(
                InvalidArgumentException::INVALID_IRI_STR,
                InvalidArgumentException::INVALID_IRI
            );
        }

        return new Iri($iri->profile, $iri->name);
    }
public static function create ( $ iri ) { // Cast as item type object if only a string is given if ( is_string ( $ iri ) ) { $ iri = ( object ) [ 'profile' => '' , 'name' => $ iri ] ; } // If the IRI is invalid if ( ! self :: validateIriStructure ( $ iri ) ) { throw new InvalidArgumentException ( InvalidArgumentException :: INVALID_IRI_STR , InvalidArgumentException :: INVALID_IRI ) ; } return new Iri ( $ iri -> profile , $ iri -> name ) ; }
Validate and sanitize an IRI

@param Iri|\stdClass|string $iri IRI

@return Iri Sanitized IRI
@throws InvalidArgumentException If the IRI is invalid
Validate and sanitize an IRI