<commit_before><?php

/**
 * Created by PhpStorm.
 * User: <NAME>
 * Date: 2015/07/07
 * Time: 11:55 AM.
 */

namespace Environment;

/**
 * Class Platform.
 */
class Platform
{
    /**
     * @var string
     */
    protected $onlineSettingDir;
    /**
     * @var array
     */
    protected $mapping;

    public function __construct($entry)
    {
        $this->onlineSettingDir = $entry;
        $this->loadFacebookPlatforms();

        if (!defined('SYS_PATH')) {
            define('SYS_PATH', __DIR__);
        }
    }

    protected function loadFacebookPlatforms()
    {
        if (is_array($this->mapping)) {
            return;
        }

        if (!is_dir($this->onlineSettingDir)) {
            return;
        }

        $dirs = array_values(array_filter(scandir($this->onlineSettingDir), function ($dir) {
            if (strpos($dir, 'facebook') === 0) {
                return $dir;
            }
        }));

        $this->mapping = [];
        foreach ($dirs as $dir) {
            $version = substr($dir, strrpos($dir, '_') + 1);
            $this->mapping[$version] = $this->onlineSettingDir.'/'.$dir;
        }
    }

    public function getMySQLShards($version)
    {
        /** @var array $all */
        $all = require $this->getPlatformSetting($version, 'database');
        assert(is_array($all));

        foreach ($all as $each) {
            if (!is_array($each)) {
                continue;
            }
            if (count($each) === 0) {
                continue;
            }

            yield $each;
        }
    }

    protected function getPlatformSetting($version, $name)
    {
        $filename = $this->mapping[$version].'/'.$name.'.php';
        assert(is_file($filename) && is_readable($filename));

        return $filename;
    }
}<commit_msg>coding standard fix: symfony2<commit_after><?php

/**
 * Created by PhpStorm.
 * User: <NAME>
 * Date: 2015/07/07
 * Time: 11:55 AM.
 */
namespace Environment;

/**
 * Class Platform.
 */
class Platform
{
    /**
     * @var string
     */
    protected $onlineSettingDir;
    /**
     * @var array
     */
    protected $mapping;

    /**
     * Platform constructor.
     *
     * @param string $entry
     */
    public function __construct($entry)
    {
        $this->onlineSettingDir = $entry;
        $this->loadFacebookPlatforms();

        if (!defined('SYS_PATH')) {
            define('SYS_PATH', __DIR__);
        }
    }

    /**
     * @param string $version
     *
     * @return \Generator
     */
    public function getMySQLShards($version)
    {
        /** @var array $all */
        $all = require $this->getPlatformSetting($version, 'database');
        assert(is_array($all));

        foreach ($all as $each) {
            if (!is_array($each)) {
                continue;
            }
            if (count($each) === 0) {
                continue;
            }

            yield $each;
        }
    }

    protected function loadFacebookPlatforms()
    {
        if (is_array($this->mapping)) {
            return;
        }

        if (!is_dir($this->onlineSettingDir)) {
            return;
        }

        $dirs = array_values(array_filter(scandir($this->onlineSettingDir), function ($dir) {
            if (strpos($dir, 'facebook') === 0) {
                return $dir;
            }
        }));

        $this->mapping = [];
        foreach ($dirs as $dir) {
            $version = substr($dir, strrpos($dir, '_') + 1);
            $this->mapping[$version] = $this->onlineSettingDir.'/'.$dir;
        }
    }

    protected function getPlatformSetting($version, $name)
    {
        $filename = $this->mapping[$version].'/'.$name.'.php';
        assert(is_file($filename) && is_readable($filename));

        return $filename;
    }
}
{'fraction_non_alphanumeric': 0.15633280339162692, 'fraction_numerical': 0.008214096449390567, 'mean_word_length': 1.7256317689530687, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '215892', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1099, 'n_words': 211}