Team Ai
Apppublic

errorcode418/php

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
ParserCommand.php40 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 UAParser\Parser;16 17class ParserCommand extends Command18{19    protected function configure()20    {21        $this22            ->setName('ua-parser:parse')23            ->setDescription('Parses a user agent string and dumps the results.')24            ->addArgument(25                'user-agent',26                null,27                InputArgument::REQUIRED,28                'User agent string to analyze'29            )30        ;31    }32 33    protected function execute(InputInterface $input, OutputInterface $output)34    {35        $result = Parser::create()->parse($input->getArgument('user-agent'));36 37        $output->writeln(json_encode($result, JSON_PRETTY_PRINT));38    }39}40