Team Ai
Apppublic

errorcode418/php

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
FetchCommand.php50 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\InputArgument;13use Symfony\Component\Console\Input\InputInterface;14use Symfony\Component\Console\Output\OutputInterface;15use Symfony\Component\Filesystem\Filesystem;16use UAParser\Util\Fetcher;17 18class FetchCommand extends Command19{20    /** @var string */21    private $defaultYamlFile;22 23    public function __construct($defaultYamlFile)24    {25        $this->defaultYamlFile = $defaultYamlFile;26        parent::__construct();27    }28 29    protected function configure()30    {31        $this32            ->setName('ua-parser:fetch')33            ->setDescription('Fetches an updated YAML file for ua-parser.')34            ->addArgument(35                'file',36                InputArgument::OPTIONAL,37                'regexes.yaml output file',38                $this->defaultYamlFile39            )40        ;41    }42 43    protected function execute(InputInterface $input, OutputInterface $output)44    {45        $fs = new Filesystem();46        $fetcher = new Fetcher();47        $fs->dumpFile($input->getArgument('file'), $fetcher->fetch());48    }49}50