toString() public static method

Returns a string representation of an object.
public static toString ( object $obj ) : string
$obj object
return string
Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $basePath = 'app/jarves/';
     $fs = new Filesystem();
     if (!$fs->exists($basePath)) {
         $output->writeln(sprintf('<error>No website data in %s</error>', $basePath));
         return;
     }
     $files = $this->import($input, $output);
     if (!$input->getOption('watch')) {
         $output->writeln("<info>Done.</info>");
     } else {
         do {
             $output->writeln("<info>Done. Wait for changes ...</info>");
             while (true) {
                 sleep(1);
                 clearstatcache();
                 foreach ($files as $path => $mtime) {
                     if ($mtime !== filemtime($path)) {
                         $output->writeln(sprintf("<info>%s changed. Reimport</info>", $path));
                         break 2;
                     }
                 }
             }
             try {
                 $files = $this->import($input, $output);
             } catch (\Exception $e) {
                 foreach ($files as $path => $mtime) {
                     $files[$path] = filemtime($path);
                 }
                 $output->writeln("<error>Failed</error>");
                 echo Debug::toString($e);
                 $output->writeln("<info>Waiting for changes ...</info>");
             }
         } while (true);
     }
 }