Simplify getData()

This commit is contained in:
Dennis Eichhorn 2023-06-09 19:33:47 +02:00
parent f88a530b96
commit ebc270c84e
2 changed files with 5 additions and 5 deletions

View File

@ -94,6 +94,9 @@ final class CliRequest extends RequestAbstract
$key = \mb_strtolower($key);
switch ($type) {
case null:
/* @phpstan-ignore-next-line */
return ArrayUtils::getArg($key, $this->data);
case 'int':
/* @phpstan-ignore-next-line */
return (int) ArrayUtils::getArg($key, $this->data);

View File

@ -99,16 +99,13 @@ abstract class RequestAbstract implements MessageInterface
}
$key = \mb_strtolower($key);
if (!isset($this->data[$key])) {
return null;
}
if ($type === null) {
return $this->data[$key];
}
switch ($type) {
case null:
return $this->data[$key];
case 'int':
return (int) $this->data[$key];
case 'string':