<commit_before><?php

namespace Whm\Opm\Client\Modules\Setup\PhantomJS\Command;

use Whm\Opm\Client\Modules\Setup\PhantomJS\Installer;

/**
 * This file is part of the Open Performance Monitor Client package
 *
 * The Open Performance Monitor collects data to measure the performance of websites
 *
 * @package OPMCLient
 */

use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Whm\Opm\Client\Console\Command;

use Symfony\Component\Validator\Constraints\NotNull;
use Whm\Opm\Client\Console\ValidatingDialog;

/**
 * Class SetupPhantomJS
 *
 * Class to install the phantomjs binary to a specific folder and
 * copy the netsniff.js script to the project directory.
 *
 * @category Command
 * @package  OPMClient
 * @license  https://raw.github.com/thewebhatesme/opm_server/master/LICENSE
 * @version  0.0.1
 * @since    2014-01-28
 * @author   <NAME> <<EMAIL>>
 */
class SetupPhantomJS extends Command
{
    /**
     * The PhantomJS Version
     * @const string
     */
    const PHANTOMJS_VERSION = '1.9.7';

    /**
     * The installation path for the binary
     * @var null
     */
    protected $installDir = null;

    protected function configure ()
    {
        $this->setName('setup:phantomjs')->setDescription('Install the phantomJS binary in the bin folder.')
             ->addOption('destination', "", InputOption::VALUE_OPTIONAL, "The directory you want phantomJS to be installed");
    }

    /**
     * Operating system dependend installation of PhantomJS
     *
     * @param InputInterface $input
     * @param OutputInterface $output
     * @throws \Exception

     * @return bool
     */
    protected function execute (InputInterface $input, OutputInterface $output)
    {
        try {
            $dialog = new ValidatingDialog($this->getHelperSet()->get('dialog'), $output);
            $this->installDir = $dialog->ask('Please enter your installation path (for example ./bin): ', new NotNull()) . PHP_EOL;
            $downloadPath = Installer::getURL(self::PHANTOMJS_VERSION);

            $output->writeln('Downloading the phantomjs binary...');
            Installer::downloadArchive($downloadPath);
            $output->writeln('Downloading was successfully.');

            $output->writeln('Install the phantomjs binary...');
            Installer::extractArchive($downloadPath, $this->installDir);
        } catch(\RuntimeException $e) {
            die('An error occured due installation routine' . PHP_EOL . $e->getMessage());
        }

        $output->writeln('Removing temporary install folder...');
        Installer::cleanup();
        $output->writeln('Installation of phantomjs completed.');<commit_msg>Added destions as command libe option for phantom setup<commit_after><?php
namespace Whm\Opm\Client\Modules\Setup\PhantomJS\Command;

use Whm\Opm\Client\Modules\Setup\PhantomJS\Installer;

/**
 * This file is part of the Open Performance Monitor Client package
 *
 * The Open Performance Monitor collects data to measure the performance of websites
 *
 * @package OPMCLient
 */
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Whm\Opm\Client\Console\Command;
use Symfony\Component\Validator\Constraints\NotNull;
use Whm\Opm\Client\Console\ValidatingDialog;

/**
 * Class SetupPhantomJS
 *
 * Class to install the phantomjs binary to a specific folder and
 * copy the netsniff.js script to the project directory.
 *
 * @category Command
 * @package OPMClient
 * @license https://raw.github.com/thewebhatesme/opm_server/master/LICENSE
 * @version 0.0.1
 * @since 2014-01-28
 * @author <NAME> <<EMAIL>>
 */
class SetupPhantomJS extends Command
{

    /**
     * The PhantomJS Version
     * @const string
     */
    const PHANTOMJS_VERSION = '1.9.7';

    /**
     * The installation path for the binary
     *
     * @var null
     */
    protected $installDir = null;

    protected function configure ()
    {
        $this->setName('setup:phantomjs')
            ->setDescription('Install the phantomJS binary in the bin folder.')
            ->addOption('destination', "", InputOption::VALUE_OPTIONAL, "The directory you want phantomJS to be installed", "");
    }

    /**
     * Operating system dependend installation of PhantomJS
     *
     * @param InputInterface $input
     * @param OutputInterface $output
     * @throws \Exception
     *
     * @return bool
     */
    protected function execute (InputInterface $input, OutputInterface $output)
    {
        try {
            $this->installDir = $input->getOption('destination');
            if ($this->installDir == "") {
                $dialog = new ValidatingDialog($this->getHelperSet()->get('dialog'), $output);
                $this->installDir = $dialog->ask('Please enter your installation path (for example ./bin): ', new NotNull()) . PHP_EOL;
            }
            $downloadPath = Installer::getURL(self::PHANTOMJS_VERSION);

            $output->writeln('Downloading the phantomjs binary...');
            Installer::downloadArchive($downloadPath);
            $output->writeln('Downloading was successfully.');

            $output->writeln('Install the phantomjs binary...');
            Installer::extractArchive($downloadPath, $this->installDir);
        } catch (\RuntimeException $e) {
            die('An error occured due installation routine' . PHP_EOL . $e->getMessage());
        }

        $output->writeln('Removing temporary install folder...');
        Installer::cleanup();
        $output->writeln('Installation of phantomjs completed.');
{'fraction_non_alphanumeric': 0.11963454576797104, 'fraction_numerical': 0.004826754007929667, 'mean_word_length': 3.080168776371308, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 40, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7250786', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1573, 'n_words': 407}