<commit_before><?php

/**
 * This file is part of the Propel package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @license MIT License
 */

namespace Propel\Generator\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Finder\Finder;

use Propel\Generator\Exception\RuntimeException;

/**
 * @author <NAME> <<EMAIL>>
 */
abstract class AbstractCommand extends Command
{
    const DEFAULT_INPUT_DIRECTORY   = '.';

    const DEFAULT_PLATFORM          = 'MysqlPlatform';

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->addOption('platform',  null, InputOption::VALUE_REQUIRED,  'The platform', self::DEFAULT_PLATFORM)
            ->addOption('input-dir', null, InputOption::VALUE_REQUIRED,  'The input directory', self::DEFAULT_INPUT_DIRECTORY)
        ;
    }

    protected function getBuildProperties($file)
    {
        $properties = array();

        if (false === $lines = @file($file)) {
            throw new RuntimeException(sprintf('Unable to parse contents of "%s".', $file));
        }

        foreach ($lines as $line) {
            $line = trim($line);

            if (empty($line) || in_array($line[0], array('#', ';'))) {
                continue;
            }

            $pos = strpos($line, '=');
            $properties[trim(substr($line, 0, $pos))] = trim(substr($line, $pos + 1));
        }<commit_msg>[Command] Avoid exception if no 'build.properties' file<commit_after><?php

/**
 * This file is part of the Propel package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @license MIT License
 */

namespace Propel\Generator\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Finder\Finder;

use Propel\Generator\Exception\RuntimeException;

/**
 * @author <NAME> <<EMAIL>>
 */
abstract class AbstractCommand extends Command
{
    const DEFAULT_INPUT_DIRECTORY   = '.';

    const DEFAULT_PLATFORM          = 'MysqlPlatform';

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->addOption('platform',  null, InputOption::VALUE_REQUIRED,  'The platform', self::DEFAULT_PLATFORM)
            ->addOption('input-dir', null, InputOption::VALUE_REQUIRED,  'The input directory', self::DEFAULT_INPUT_DIRECTORY)
        ;
    }

    protected function getBuildProperties($file)
    {
        $properties = array();

        if (file_exists($file)) {
            if (false === $lines = @file($file)) {
                throw new RuntimeException(sprintf('Unable to parse contents of "%s".', $file));
            }

            foreach ($lines as $line) {
                $line = trim($line);

                if (empty($line) || in_array($line[0], array('#', ';'))) {
                    continue;
                }

                $pos = strpos($line, '=');
                $properties[trim(substr($line, 0, $pos))] = trim(substr($line, $pos + 1));
            }
        }
{'fraction_non_alphanumeric': 0.13613861386138615, 'fraction_numerical': 0.0018564356435643563, 'mean_word_length': 2.5605726872246697, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '3100384', 'n_tokens_mistral': 911, 'n_tokens_neox': 896, 'n_words': 226}