Team Ai
Apppublic

errorcode418/php

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
UpdateCommand.php51 linesDownload Raw Back to Command
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\InputInterface;13use Symfony\Component\Console\Input\InputOption;14use Symfony\Component\Console\Output\OutputInterface;15use UAParser\Util\Converter;16use UAParser\Util\Fetcher;17 18class UpdateCommand extends Command19{20    /** @var string */21    private $resourceDirectory;22 23    public function __construct($resourceDirectory)24    {25        $this->resourceDirectory = $resourceDirectory;26        parent::__construct();27    }28 29    protected function configure()30    {31        $this32            ->setName('ua-parser:update')33            ->setDescription('Fetches an updated YAML file for ua-parser and overwrites the current PHP file.')34            ->addOption(35                'no-backup',36                null,37                InputOption::VALUE_NONE,38                'Do not backup the previously existing file'39            )40        ;41    }42 43    protected function execute(InputInterface $input, OutputInterface $output)44    {45        $fetcher = new Fetcher();46        $converter = new Converter($this->resourceDirectory);47 48        $converter->convertString($fetcher->fetch(), !$input->getOption('no-backup'));49    }50}51