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 IntegerArgumentType extends ArgumentType {
function __construct(\CharlotteDunois\Livia\Client $client) {
parent::__construct($client, 'integer');
}
* @return bool|string|\React\Promise\ExtendedPromiseInterface
function validate(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
$value = \filter_var($value, \FILTER_VALIDATE_INT);
if($value === false) {
return false;
if($arg->min !== null && $value < $arg->min) {
return 'Please enter a number above or exactly '.$arg->min.'.';
if($arg->max !== null && $value > $arg->max) {
return 'Please enter a number below or exactly '.$arg->max.'.';
return true;
* @return mixed|null|\React\Promise\ExtendedPromiseInterface
function parse(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) {
return ((int) $value);