|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
-
- namespace App\Console\Commands;
-
- use Illuminate\Console\Command;
- use App\Patrones\Singleton\Logger;
-
- class Singleton extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'singleton';
-
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Prueba del patron de diseño singleton';
-
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
-
- $this->info('Comando que permitira hacer pruebas del patron de diseño Singleton');
- Logger::log("Started!");
- // Compare values of Logger singleton.
- $l1 = Logger::getInstance();
- //$this->line(unserialize(serialize($l1)));
- $l2 = Logger::getInstance();
- if ($l1 === $l2) {
- Logger::log("Logger has a single instance.");
- } else {
- Logger::log("Loggers are different.");
- }
- Logger::log("Finished!");
- return Command::SUCCESS;
- }
- }
|