Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

47 řádky
1.1 KiB

  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Patrones\Singleton\Logger;
  5. class Singleton extends Command
  6. {
  7. /**
  8. * The name and signature of the console command.
  9. *
  10. * @var string
  11. */
  12. protected $signature = 'singleton';
  13. /**
  14. * The console command description.
  15. *
  16. * @var string
  17. */
  18. protected $description = 'Prueba del patron de diseño singleton';
  19. /**
  20. * Execute the console command.
  21. *
  22. * @return int
  23. */
  24. public function handle()
  25. {
  26. $this->info('Comando que permitira hacer pruebas del patron de diseño Singleton');
  27. Logger::log("Started!");
  28. // Compare values of Logger singleton.
  29. $l1 = Logger::getInstance();
  30. //$this->line(unserialize(serialize($l1)));
  31. $l2 = Logger::getInstance();
  32. if ($l1 === $l2) {
  33. Logger::log("Logger has a single instance.");
  34. } else {
  35. Logger::log("Loggers are different.");
  36. }
  37. Logger::log("Finished!");
  38. return Command::SUCCESS;
  39. }
  40. }