Browscap\Writer\Factory\FullPhpWriterFactory::createCollection PHP Method

createCollection() public method

public createCollection ( Psr\Log\LoggerInterface $logger, string $buildFolder, string | null $file = null ) : WriterCollection
$logger Psr\Log\LoggerInterface
$buildFolder string
$file string | null
return Browscap\Writer\WriterCollection
    public function createCollection(LoggerInterface $logger, $buildFolder, $file = null)
    {
        $writerCollection = new WriterCollection();
        if (null === $file) {
            $file = $buildFolder . '/full_php_browscap.ini';
        }
        $fullFilter = new FullFilter();
        $fullPhpWriter = new IniWriter($file);
        $formatter = new PhpFormatter();
        $fullPhpWriter->setLogger($logger)->setFormatter($formatter->setFilter($fullFilter))->setFilter($fullFilter);
        return $writerCollection->addWriter($fullPhpWriter);
    }

Usage Example

Example #1
0
 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @throws \LogicException When this abstract method is not implemented
  * @return null|int        null or 0 if everything went fine, or an error code
  *
  * @see    setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $leftFilename = $input->getArgument('left');
     $rightFilename = $input->getArgument('right');
     $debug = $input->getOption('debug');
     $loggerHelper = new LoggerHelper();
     $logger = $loggerHelper->create($debug);
     if (!$rightFilename || !file_exists($rightFilename)) {
         $logger->info('right file not set or invalid - creating right file from resources');
         $cacheDir = sys_get_temp_dir() . '/browscap-diff/' . microtime(true) . '/';
         $rightFilename = $cacheDir . 'full_php_browscap.ini';
         if (!file_exists($cacheDir)) {
             mkdir($cacheDir, 0777, true);
         }
         $buildGenerator = new BuildGenerator($input->getOption('resources'), $cacheDir);
         $writerCollectionFactory = new FullPhpWriterFactory();
         $writerCollection = $writerCollectionFactory->createCollection($logger, $cacheDir);
         $buildGenerator->setLogger($logger)->setCollectionCreator(new CollectionCreator())->setWriterCollection($writerCollection);
         $buildGenerator->run($input->getArgument('version'), false);
     }
     $generator = new DiffGenerator();
     $generator->setLogger($logger)->run($leftFilename, $rightFilename);
     $logger->info('Diff done.');
 }
All Usage Examples Of Browscap\Writer\Factory\FullPhpWriterFactory::createCollection
FullPhpWriterFactory