private function initializeFromSimpleXML($xmlObject)
    {
        $this->path = !empty($xmlObject->path) ? trim($xmlObject->path) : '/';
        $this->name = !empty($xmlObject->name) ? trim($xmlObject->name) : '';
        $this->class = !empty($xmlObject->class) ? trim($xmlObject->class) : '';

        $this->priority = !empty($xmlObject->priority) ? intval($xmlObject->priority) : 0;

        $this->patternString = !empty($xmlObject->pattern) ? (string)$xmlObject->pattern : null;
        $this->pattern = !empty($this->patternString) ? new Pattern($this->path, $this->patternString) : null;

        $this->parameters = new \stdClass();

        //Build route parameters into an object because SimpleXMLElements can't be memcached
        if (!empty($xmlObject->parameters) && $xmlObject->parameters->children()) {
            foreach ($xmlObject->parameters->children() as $parameter) {
                $parameterName = (string)$parameter->getName();
                $parameterValue = (string)$parameter;
                $parameterAttributes = [];

                $attributes = $parameter->attributes();
                foreach ($attributes as $attributeName => $attributeValue) {
                    $parameterAttributes[(string)$attributeName] = (string)$attributeValue;
                }

                $parameterObject = new \Slab\Router\Parameter($parameterName, $parameterValue, $parameterAttributes);

                if (!empty($this->parameters->$parameterName)) {
                    if (is_array($this->parameters->$parameterName)) {
                        $this->parameters->{$parameterName}[] = $parameterObject;
                    } else {
                        $this->parameters->$parameterName = array($this->parameters->$parameterName, $parameterObject);
                    }
                } else {
                    $this->parameters->$parameterName = $parameterObject;
                }
            }
        }
    }
private function initializeFromSimpleXML($xmlObject)
    {
        $this->path = !empty($xmlObject->path) ? trim($xmlObject->path) : '/';
        $this->name = !empty($xmlObject->name) ? trim($xmlObject->name) : '';
        $this->class = !empty($xmlObject->class) ? trim($xmlObject->class) : '';

        $this->priority = !empty($xmlObject->priority) ? intval($xmlObject->priority) : 0;

        $this->patternString = !empty($xmlObject->pattern) ? (string)$xmlObject->pattern : null;
        $this->pattern = !empty($this->patternString) ? new Pattern($this->path, $this->patternString) : null;

        $this->parameters = new \stdClass();

        //Build route parameters into an object because SimpleXMLElements can't be memcached
        if (!empty($xmlObject->parameters) && $xmlObject->parameters->children()) {
            foreach ($xmlObject->parameters->children() as $parameter) {
                $parameterName = (string)$parameter->getName();
                $parameterValue = (string)$parameter;
                $parameterAttributes = [];

                $attributes = $parameter->attributes();
                foreach ($attributes as $attributeName => $attributeValue) {
                    $parameterAttributes[(string)$attributeName] = (string)$attributeValue;
                }

                $parameterObject = new \Slab\Router\Parameter($parameterName, $parameterValue, $parameterAttributes);

                if (!empty($this->parameters->$parameterName)) {
                    if (is_array($this->parameters->$parameterName)) {
                        $this->parameters->{$parameterName}[] = $parameterObject;
                    } else {
                        $this->parameters->$parameterName = array($this->parameters->$parameterName, $parameterObject);
                    }
                } else {
                    $this->parameters->$parameterName = $parameterObject;
                }
            }
        }
    }
private function initializeFromSimpleXML ( $ xmlObject ) { $ this -> path = ! empty ( $ xmlObject -> path ) ? trim ( $ xmlObject -> path ) : '/' ; $ this -> name = ! empty ( $ xmlObject -> name ) ? trim ( $ xmlObject -> name ) : '' ; $ this -> class = ! empty ( $ xmlObject -> class ) ? trim ( $ xmlObject -> class ) : '' ; $ this -> priority = ! empty ( $ xmlObject -> priority ) ? intval ( $ xmlObject -> priority ) : 0 ; $ this -> patternString = ! empty ( $ xmlObject -> pattern ) ? ( string ) $ xmlObject -> pattern : null ; $ this -> pattern = ! empty ( $ this -> patternString ) ? new Pattern ( $ this -> path , $ this -> patternString ) : null ; $ this -> parameters = new \ stdClass ( ) ; //Build route parameters into an object because SimpleXMLElements can't be memcached if ( ! empty ( $ xmlObject -> parameters ) && $ xmlObject -> parameters -> children ( ) ) { foreach ( $ xmlObject -> parameters -> children ( ) as $ parameter ) { $ parameterName = ( string ) $ parameter -> getName ( ) ; $ parameterValue = ( string ) $ parameter ; $ parameterAttributes = [ ] ; $ attributes = $ parameter -> attributes ( ) ; foreach ( $ attributes as $ attributeName => $ attributeValue ) { $ parameterAttributes [ ( string ) $ attributeName ] = ( string ) $ attributeValue ; } $ parameterObject = new \ Slab \ Router \ Parameter ( $ parameterName , $ parameterValue , $ parameterAttributes ) ; if ( ! empty ( $ this -> parameters -> $ parameterName ) ) { if ( is_array ( $ this -> parameters -> $ parameterName ) ) { $ this -> parameters -> { $ parameterName } [ ] = $ parameterObject ; } else { $ this -> parameters -> $ parameterName = array ( $ this -> parameters -> $ parameterName , $ parameterObject ) ; } } else { $ this -> parameters -> $ parameterName = $ parameterObject ; } } } }
Initialize from a simple XML object

@param \SimpleXMLElement $xmlObject
@throws \Exception
Initialize from a simple XML object