initial commit
This commit is contained in:
parent
f614837729
commit
b536316a84
68
src/Controller/Commands/Command.php
Normal file
68
src/Controller/Commands/Command.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Commands;
|
||||
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Command
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $name,
|
||||
private readonly Closure $callback,
|
||||
private readonly array $mandatoryParameters = [],
|
||||
private readonly array $optionalParameters = [],
|
||||
private readonly string $description = ''
|
||||
)
|
||||
{
|
||||
// no body
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMandatoryParameters(): array
|
||||
{
|
||||
return $this->mandatoryParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionalParameters(): array
|
||||
{
|
||||
return $this->optionalParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Closure
|
||||
*/
|
||||
public function getCallback(): Closure
|
||||
{
|
||||
return $this->callback;
|
||||
}
|
||||
|
||||
public function exec(): void
|
||||
{
|
||||
call_user_func(callback: $this->callback);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user