<commit_before><?php

/*
 * This file is part of PHP-FFmpeg.
 *
 * (c) Alchemy <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace FFMpeg;

abstract class Binary implements AdapterInterface
{

    protected $binary;

    /**
     *
     * @var \Monolog\Logger
     */
    protected $logger;

    public function __construct($binary, $logger = null)
    {
        $this->binary = $binary;

        if ( ! $logger)
        {
            $logger = new \Monolog\Logger('default');
            $logger->pushHandler(new \Monolog\Handler\NullHandler());
        }

        $this->logger = $logger;
    }

    public static function load(\Monolog\Logger $logger = null)
    {
        if ('' === $binary = self::autodetect(static::getBinaryName()))
        {
            throw new Exception\BinaryNotFoundException('Binary not found');
        }

        return new static($binary, $logger);
    }

    protected static function run($command, $bypass_errors = false)
    {
        $process = new \Symfony\Component\Process\Process($command);
        $process->run();

        if ( ! $process->isSuccessful() && ! $bypass_errors)
        {
            throw new \RuntimeException('Failed to execute ' . $command);
        }

        $result = $process->getOutput();
        unset($process);

        return $result;
    }

    /**
     * Autodetect the presence of a binary
     *
     * @param   string      $binaryName
     * @return  string
     */
    protected static function autodetect($binaryName)
    {
        return trim(self::run(sprintf('which %s', escapeshellarg($binaryName)), true));
    }

    protected static function getBinaryName()
    {
        throw new Exception('Should be implemented');
    }

}<commit_msg>Use Symfony ExecutableFinder instead of custom autodetect method<commit_after><?php

/*
 * This file is part of PHP-FFmpeg.
 *
 * (c) Alchemy <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace FFMpeg;

abstract class Binary implements AdapterInterface
{

    protected $binary;

    /**
     *
     * @var \Monolog\Logger
     */
    protected $logger;

    public function __construct($binary, $logger = null)
    {
        $this->binary = $binary;

        if ( ! $logger)
        {
            $logger = new \Monolog\Logger('default');
            $logger->pushHandler(new \Monolog\Handler\NullHandler());
        }

        $this->logger = $logger;
    }

    public static function load(\Monolog\Logger $logger = null)
    {
        $finder = new \Symfony\Component\Process\ExecutableFinder();

        if (null === $binary = $finder->find(static::getBinaryName()))
        {
            throw new Exception\BinaryNotFoundException('Binary not found');
        }

        return new static($binary, $logger);
    }

    protected static function run($command, $bypass_errors = false)
    {
        $process = new \Symfony\Component\Process\Process($command);
        $process->run();

        if ( ! $process->isSuccessful() && ! $bypass_errors)
        {
            throw new \RuntimeException('Failed to execute ' . $command);
        }

        $result = $process->getOutput();
        unset($process);

        return $result;
    }

    protected static function getBinaryName()
    {
        throw new Exception('Should be implemented');
    }

}
{'fraction_non_alphanumeric': 0.12442660550458716, 'fraction_numerical': 0.0, 'mean_word_length': 2.285310734463277, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5071904', 'n_tokens_mistral': 979, 'n_tokens_neox': 949, 'n_words': 249}