| Total Complexity | 8 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class StringArgumentType extends ArgumentType { |
||
| 17 | /** |
||
| 18 | * @internal |
||
| 19 | */ |
||
| 20 | function __construct(\CharlotteDunois\Livia\Client $client) { |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * {@inheritdoc} |
||
| 26 | * @return bool|string|\React\Promise\ExtendedPromiseInterface |
||
| 27 | */ |
||
| 28 | function validate(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) { |
||
| 29 | if(\mb_strlen($value) === 0) { |
||
| 30 | return false; |
||
| 31 | } |
||
| 32 | |||
| 33 | if($arg->min !== null && \mb_strlen($value) < $arg->min) { |
||
| 34 | return 'Please enter something above or exactly '.$arg->min.' characters in length.'; |
||
| 35 | } |
||
| 36 | |||
| 37 | if($arg->max !== null && \mb_strlen($value) > $arg->max) { |
||
| 38 | return 'Please enter a number below or exactly '.$arg->max.' characters in length.'; |
||
| 39 | } |
||
| 40 | |||
| 41 | return true; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | * @return mixed|null|\React\Promise\ExtendedPromiseInterface |
||
| 47 | */ |
||
| 48 | function parse(string $value, \CharlotteDunois\Livia\Commands\Context $context, ?\CharlotteDunois\Livia\Arguments\Argument $arg = null) { |
||
| 50 | } |
||
| 51 | } |
||
| 52 |