for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Livia
* Copyright 2017-2019 Charlotte Dunois, All Rights Reserved
*
* Website: https://charuru.moe
* License: https://github.com/CharlotteDunois/Livia/blob/master/LICENSE
*/
namespace CharlotteDunois\Livia\Types;
* {@inheritdoc}
* @internal
class CommandArgumentType extends ArgumentType {
function __construct(\CharlotteDunois\Livia\Client $client) {
parent::__construct($client, 'command');
}
* @return bool|string|\React\Promise\ExtendedPromiseInterface
function validate(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
$commands = $this->client->registry->findCommands($value);
if(\count($commands) === 1) {
return true;
if(\count($commands) === 0) {
return false;
return \CharlotteDunois\Livia\Utils\DataHelpers::disambiguation($commands, 'commands', 'name').\PHP_EOL;
* @return mixed|null|\React\Promise\ExtendedPromiseInterface
function parse(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
if(\count($commands) > 0) {
return $commands[0];
return null;