File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change @@ -17,19 +17,12 @@ composer require devlop/laravel-console-input-validation
1717
1818``` php
1919use Devlop\Laravel\Console\ValidateInput;
20- use InvalidArgumentException;
2120use Symfony\Component\Console\Input\InputInterface;
22- use Webmozart\Assert\Assert; // not required, but used in the example below
2321
2422class DemoCommand extends Command
2523{
2624 use ValidateInput;
2725
28- public function __construct()
29- {
30- parent::__construct();
31- }
32-
3326 /**
3427 * Validate the console command input.
3528 *
@@ -39,10 +32,10 @@ class DemoCommand extends Command
3932 {
4033 // Example using manual validation
4134 if (! is_numeric($input->getOption('limit'))) {
42- throw new RuntimeException ('--limit must be numeric');
35+ throw new InvalidArgumentException ('--limit must be numeric');
4336 }
4437
45- // Example using webmozarts/assert:
38+ // Example using webmozarts/assert
4639 Assert::numeric($input->getOption('limit')); // assert that the --limit option got a numeric value
4740 Assert::greaterThan($input->getOption('limit'), 0); // assert that the --limit option get a value greater than 0
4841 }
You can’t perform that action at this time.
0 commit comments