TestCommand.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Nerd\CartesianProduct\CartesianProduct;
  5. class TestCommand extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'test {cmd?}';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'Command description';
  19. public function handle()
  20. {
  21. $cmd = $this->argument('cmd');
  22. $args = $this->arguments();
  23. unset($args['command'], $args['cmd']);
  24. $params = array_values($args);
  25. if (empty($cmd)) {
  26. echo 'Nothing to do...';
  27. } else {
  28. if (method_exists($this, $cmd)) {
  29. call_user_func_array([$this, $cmd], $params);
  30. } else {
  31. echo 'cmd not exists';
  32. }
  33. }
  34. return;
  35. }
  36. public function time()
  37. {
  38. $cartesianProduct = new CartesianProduct();
  39. $cartesianProduct->appendSet(["红色", "白色"]);
  40. dump($cartesianProduct->compute());
  41. }
  42. }