private function getopt()
    {

        // Reset option argument
        $this->optarg = null;
        
        // Check for index validity
        if ($this->optind >= $this->argc) {
            return -1;
        }

        // Get a copy of the current option to examine
        $arg = $this->argv[$this->optind];

        if ($this->isLongOption($arg)) {
            return $this->parseLongOption($arg);
        }

        if ($this->isShortOption($arg)) {
            return $this->parseShortOption($arg);
        }

        // If it's not an option, it's an argument,
        // so we stop parsing at the first non-option string
        // and $this->optind points to the first argument

        // Default: no options found
        return -1;
    }