improve cli argument handling

This commit is contained in:
Dennis Eichhorn 2022-03-28 21:28:38 +02:00
parent c1fb9a31dc
commit e2b842c29d
5 changed files with 13 additions and 8 deletions

View File

@ -111,6 +111,13 @@ final class ConsoleRequest extends RequestAbstract
}
}
public function hasData(string $key) : bool
{
$key = '-' . \mb_strtolower($key);
return ArrayUtils::hasArg($key, $this->data) > -1;
}
/**
* Set request data.
*

View File

@ -14,9 +14,7 @@ declare(strict_types=1);
namespace phpOMS\Module;
use Modules\Admin\Models\PermissionAbstractMapper;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\System\MimeType;

View File

@ -16,7 +16,6 @@ namespace phpOMS\Module;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\Application\ApplicationInfo;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\System\File\Local\Directory;
use phpOMS\System\File\Local\File;
use phpOMS\System\File\PathException;

View File

@ -169,6 +169,9 @@ final class Argument implements UriInterface
$uriParts = \explode(' ', $uri);
// Handle no path information only data
$uriParts = \stripos($uriParts[0], '-') === 0 ? ['/', $uriParts[0]] : $uriParts;
$this->path = \array_shift($uriParts);
$this->pathElements = \explode('/', \ltrim($this->path, '/'));

View File

@ -292,11 +292,9 @@ final class ArrayUtils
*/
public static function hasArg(string $id, array $args) : int
{
if (($key = \array_search($id, $args)) === false) {
return -1;
}
return (int) $key;
return ($key = \array_search($id, $args)) === false
? -1
: (int) $key;
}
/**