Add HTTP method to App\Arguments

This commit is contained in:
Philipp 2022-01-02 22:21:41 +01:00
parent c7f2ba213b
commit ee2a15d822
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
2 changed files with 40 additions and 2 deletions

View file

@ -52,14 +52,19 @@ class Arguments
* @var int The count of arguments
*/
private $argc;
/**
* @var string The used HTTP method
*/
private $method;
public function __construct(string $queryString = '', string $command = '', string $moduleName = '', array $argv = [], int $argc = 0)
public function __construct(string $queryString = '', string $command = '', string $moduleName = '', array $argv = [], int $argc = 0, string $method = Router::GET)
{
$this->queryString = $queryString;
$this->command = $command;
$this->moduleName = $moduleName;
$this->argv = $argv;
$this->argc = $argc;
$this->method = $method;
}
/**
@ -94,6 +99,11 @@ class Arguments
return $this->argv;
}
public function getMethod()
{
return $this->method;
}
/**
* @return int The count of arguments of this call
*/
@ -199,6 +209,8 @@ class Arguments
$module = "login";
}
return new Arguments($queryString, $command, $module, $argv, $argc);
$httpMethod = in_array($server['REQUEST_METHOD'] ?? '', Router::ALLOWED_METHODS) ? $server['REQUEST_METHOD'] : Router::GET;
return new Arguments($queryString, $command, $module, $argv, $argc, $httpMethod);
}
}