<commit_before><?php
/**
 * Created by PhpStorm.
 * User: bryce
 * Date: 5/3/15
 * Time: 10:27 PM
 */

namespace WordWrap\Configuration;

use \Exception;
/**
 * This class is what will handle the parsing of the configuration json, and storing of it
 *
 * Class Factory
 * @package WordWrap\Configuration
 */

class Factory {


    /**
     * @param $pluginName string the name of the plugin that we are reading the configuration for
     * @throws Exception The json file should be located at the root of the plugin, and it should be named info.json
     *                      if it isn't then we have no idea what this plugin is about
     * @return Base We will be constructing an instance of our Base configuration and returning it
     */
    public static function inflate($pluginName) {

    }

    //TODO create a function to write out an instance of base to file
}<commit_msg>filled out function body for inflating the configuration<commit_after><?php
/**
 * Created by PhpStorm.
 * User: bryce
 * Date: 5/3/15
 * Time: 10:27 PM
 */

namespace WordWrap\Configuration;

use \Exception;
/**
 * This class is what will handle the parsing of the configuration json, and storing of it
 *
 * Class Factory
 * @package WordWrap\Configuration
 */

class Factory {


    /**
     * @param $pluginName string the name of the plugin that we are reading the configuration for
     * @throws Exception The json file should be located at the root of the plugin, and it should be named info.json
     *                      if it isn't then we have no idea what this plugin is about
     * @return Root We will be constructing an instance of our Root configuration and returning it
     */
    public static function inflate($pluginName) {
        $path = get_home_path() . "wp-content/plugins/" . $pluginName . "/info.json";
        if(!file_exists($path))
            throw new Exception("Unable to find plugin configuration. Please make sure that you have a info.json included in the root of your plugin");

        $fileContents = file_get_contents($path);
        $json = json_decode($fileContents, true);

        return new Root($json);
    }

    //TODO create a function to write out an instance of base to file
}
{'fraction_non_alphanumeric': 0.0776173285198556, 'fraction_numerical': 0.007220216606498195, 'mean_word_length': 2.8422876949740035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6698165', 'n_tokens_mistral': 597, 'n_tokens_neox': 568, 'n_words': 277}