<commit_before><?php

namespace Modules\Content\Platform;

use Nova\Container\Container;


abstract class ContentTypeManager
{
    /**
     * @var \Nova\Container\Container
     */
    protected $container;

    /**
     * @var array
     */
    protected $types = array();


    public function __construct(Container $container)
    {
        $this->container = $container;
    }

    abstract public function register($className, array $options = array());

    public function forget($type)
    {
        unset($this->types[$type]);
    }

    public function make($type)
    {
        if (isset($this->types[$type])) {
            return $this->types[$type];
        }
    }

    public function getTypes()
    {
        return array_values($this->types);
    }

    public function getModelByType($type)
    {
        if (! is_null($instance = $this->get($type))) {
            return $instance->model();
        }
    }

    public function getRouteSlugs($plural = true)
    {
        $result = array();

        foreach ($this->types as $name => $type) {
            if (! $type->isHidden()) {
                $result[] = $type->slug($plural);
            }
        }

        return $result;
    }

    public function getCurrentLocale()
    {
        $languageManager = $this->container['language'];

        return $languageManager->getLocale();
    }
}
<commit_msg>Improve the Content module<commit_after><?php

namespace Modules\Content\Platform;

use Nova\Container\Container;

use InvalidArgumentException;


abstract class ContentTypeManager
{
    /**
     * @var \Nova\Container\Container
     */
    protected $container;

    /**
     * @var array
     */
    protected $types = array();


    public function __construct(Container $container)
    {
        $this->container = $container;
    }

    abstract public function register($className, array $options = array());

    public function forget($type)
    {
        unset($this->types[$type]);
    }

    public function make($type)
    {
        if (isset($this->types[$type])) {
            return $this->types[$type];
        }

        throw new InvalidArgumentException("The Content type [{$type}] is not registered");
    }

    public function getTypes()
    {
        return array_values($this->types);
    }

    public function getModelByType($type)
    {
        try {
            $instance = $this->make($type);

            return $instance->model();
        }
        catch (InvalidArgumentException $e) {
            // Nothing to do.
        }
    }

    public function getRouteSlugs($plural = true)
    {
        $result = array();

        foreach ($this->types as $name => $type) {
            if (! $type->isHidden()) {
                $result[] = $type->slug($plural);
            }
        }

        return $result;
    }

    public function getCurrentLocale()
    {
        $languageManager = $this->container['language'];

        return $languageManager->getLocale();
    }
}

{'fraction_non_alphanumeric': 0.1366689053055742, 'fraction_numerical': 0.0, 'mean_word_length': 2.0429009193054135, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '2132954', 'n_tokens_mistral': 835, 'n_tokens_neox': 804, 'n_words': 176}