Untitled

mail@pastecode.io avatar
unknown
php
a year ago
801 B
1
Indexable
# Antes
protected function parse()
{
    foreach ($this->parameters as $key => $value) {
        if (0 === strpos($key, '--')) {
            $this->addLongOption(substr($key, 2), $value);
        } elseif ('-' === $key[0]) {
            $this->addShortOption(substr($key, 1), $value);
        } else {
            $this->addArgument($key, $value);
        }
    }
}

# Depois
protected function parse()
{
    foreach ($this->parameters as $key => $value) {
        if ('--' === $key) {
            return;
        }

        if (0 === strpos($key, '--')) {
            $this->addLongOption(substr($key, 2), $value);
        } elseif (0 === strpos($key, '-')) {
            $this->addShortOption(substr($key, 1), $value);
        } else {
            $this->addArgument($key, $value);
        }
    }
}