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 GroupArgumentType extends ArgumentType {
function __construct(\CharlotteDunois\Livia\Client $client) {
parent::__construct($client, 'group');
}
* @return bool|string|\React\Promise\ExtendedPromiseInterface
function validate(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
$groups = $this->client->registry->findGroups($value);
if(\count($groups) === 1) {
return true;
if(\count($groups) === 0) {
return false;
return \CharlotteDunois\Livia\Utils\DataHelpers::disambiguation($groups, 'groups', '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($groups) > 0) {
return $groups[0];
return null;