src/Components/Host.php
protected function validate($data)
    {
        $data = $this->validateSegment($data);
        if (! $data) {
            return $data;
        }

        $this->saveInternalEncoding();
        if (! $this->isValidHostLength($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid hostname, check its length');
        }

        if (! $this->isValidHostPattern($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid host label, check its content');
        }

        if (! $this->isValidHostLabels($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid host label counts, check its count');
        }

        $data = $this->sanitizeValue($data);
        $data = explode(
            $this->delimiter,
            $this->punycode->decode(implode($this->delimiter, $data))
        );
        $this->restoreInternalEncoding();

        return $data;
    }
protected function validate($data)
    {
        $data = $this->validateSegment($data);
        if (! $data) {
            return $data;
        }

        $this->saveInternalEncoding();
        if (! $this->isValidHostLength($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid hostname, check its length');
        }

        if (! $this->isValidHostPattern($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid host label, check its content');
        }

        if (! $this->isValidHostLabels($data)) {
            $this->restoreInternalEncoding();
            throw new RuntimeException('Invalid host label counts, check its count');
        }

        $data = $this->sanitizeValue($data);
        $data = explode(
            $this->delimiter,
            $this->punycode->decode(implode($this->delimiter, $data))
        );
        $this->restoreInternalEncoding();

        return $data;
    }
protected function validate ( $ data ) { $ data = $ this -> validateSegment ( $ data ) ; if ( ! $ data ) { return $ data ; } $ this -> saveInternalEncoding ( ) ; if ( ! $ this -> isValidHostLength ( $ data ) ) { $ this -> restoreInternalEncoding ( ) ; throw new RuntimeException ( 'Invalid hostname, check its length' ) ; } if ( ! $ this -> isValidHostPattern ( $ data ) ) { $ this -> restoreInternalEncoding ( ) ; throw new RuntimeException ( 'Invalid host label, check its content' ) ; } if ( ! $ this -> isValidHostLabels ( $ data ) ) { $ this -> restoreInternalEncoding ( ) ; throw new RuntimeException ( 'Invalid host label counts, check its count' ) ; } $ data = $ this -> sanitizeValue ( $ data ) ; $ data = explode ( $ this -> delimiter , $ this -> punycode -> decode ( implode ( $ this -> delimiter , $ data ) ) ) ; $ this -> restoreInternalEncoding ( ) ; return $ data ; }
Validate Host data before insertion into a URL host component

@param mixed $data the data to insert

@return array

@throws RuntimeException If the added is invalid
Validate Host data before insertion into a URL host component