errorcode418/php
0
1<?php2/**3 * ua-parser4 *5 * Copyright (c) 2011-2012 Dave Olsen, http://dmolsen.com6 *7 * Released under the MIT license8 */9namespace UAParser\Command;10 11use Symfony\Component\Console\Command\Command;12use Symfony\Component\Console\Input\InputArgument;13use Symfony\Component\Console\Input\InputInterface;14use Symfony\Component\Console\Input\InputOption;15use Symfony\Component\Console\Output\OutputInterface;16use UAParser\Util\Converter;17 18class ConvertCommand extends Command19{20 /** @var string */21 private $resourceDirectory;22 23 /** @var string */24 private $defaultYamlFile;25 26 public function __construct($resourceDirectory, $defaultYamlFile)27 {28 $this->resourceDirectory = $resourceDirectory;29 $this->defaultYamlFile = $defaultYamlFile;30 parent::__construct();31 }32 33 protected function configure()34 {35 $this36 ->setName('ua-parser:convert')37 ->setDescription('Converts an existing regexes.yaml file to a regexes.php file.')38 ->addArgument(39 'file',40 InputArgument::OPTIONAL,41 'Path to the regexes.yaml file',42 $this->defaultYamlFile43 )44 ->addOption(45 'no-backup',46 null,47 InputOption::VALUE_NONE,48 'Do not backup the previously existing file'49 )50 ;51 }52 53 protected function execute(InputInterface $input, OutputInterface $output)54 {55 $this->getConverter()->convertFile($input->getArgument('file'), $input->getOption('no-backup'));56 }57 58 private function getConverter()59 {60 return new Converter($this->resourceDirectory);61 }62}63 