public function getSegments($named = false) {
        if (!empty($this->segments)) {
            return $named === true ? $this->segmentsNamed : $this->segments;
        }

        // required parameters
        $required = $this->defaults;

        // escape special characters
        $safeTemplate = $this->escapeTemplate($this->template);

        // extract segments
        $this->segments = $this->extractSegments($this, $safeTemplate, $required);

        return $named === true ? $this->segmentsNamed : $this->segments;
    }