<commit_before><?php

namespace Octo;

use b8\Config;
use Octo\Module;

class ModuleManager
{
    /**
     * @var \b8\Config
     */
    protected $config;

    protected $modules;

    protected $moduleObjects;

    public function __construct()
    {
        $this->modules = [];
    }

    public function setConfig(Config $config)
    {
        $this->config = $config;
        $this->config->set('ModuleManager', $this);
    }

    public function getEnabled()
    {
        return $this->modules;
    }

    public function initialiseModules()
    {
        foreach ($this->moduleObjects as $module) {
            $module->init();
        }
    }

    public function enable($namespace, $module)
    {
        if (!isset($this->modules[$namespace])) {
            $this->modules[$namespace] = [];
        }

        if (!in_array($module, $this->modules[$namespace])) {
            $this->modules[$namespace][] = $module;

            // Create the object:
            $class = '\\' . $namespace . '\\' . $module . '\\Module';
            $this->moduleObjects[$module] = new $class($this, $this->config, $namespace);
        }
    }
}<commit_msg>Adding isEnabled() to ModuleManager.<commit_after><?php

namespace Octo;

use b8\Config;
use Octo\Module;

class ModuleManager
{
    /**
     * @var \b8\Config
     */
    protected $config;

    protected $modules;

    protected $moduleObjects;

    public function __construct()
    {
        $this->modules = [];
    }

    public function setConfig(Config $config)
    {
        $this->config = $config;
        $this->config->set('ModuleManager', $this);
    }

    public function getEnabled()
    {
        return $this->modules;
    }
    
    public function isEnabled($module)
    {
        return isset($this->modules[$module]);
    }

    public function initialiseModules()
    {
        foreach ($this->moduleObjects as $module) {
            $module->init();
        }
    }

    public function enable($namespace, $module)
    {
        if (!isset($this->modules[$namespace])) {
            $this->modules[$namespace] = [];
        }

        if (!in_array($module, $this->modules[$namespace])) {
            $this->modules[$namespace][] = $module;

            // Create the object:
            $class = '\\' . $namespace . '\\' . $module . '\\Module';
            $this->moduleObjects[$module] = new $class($this, $this->config, $namespace);
        }
    }
}
{'fraction_non_alphanumeric': 0.15925925925925927, 'fraction_numerical': 0.0016460905349794238, 'mean_word_length': 2.0311720698254363, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '3061802', 'n_tokens_mistral': 712, 'n_tokens_neox': 696, 'n_words': 140}