<commit_before><?php

namespace Modules\Content\Platform\Types;

use Nova\Support\Arr;
use Nova\Support\Str;

use Modules\Content\Platform\ContentManager;
use Modules\Content\Platform\PostManager;


abstract class Content
{
    /**
     * @var \Modules\Content\Platform\ContentManager
     */
    protected $manager;

    /**
     * @var string
     */
    protected $name;

    /**
     * @var string
     */
    protected $model;

    /**
     * @var bool
     */
    protected $hidden = false;

    /**
     * @var bool
     */
    protected $public = true;

    /**
     * @var bool
     */
    protected $hierarchical = false;

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

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


    public function __construct(ContentManager $manager, array $options)
    {
        $this->manager = $manager;

        //
        unset($options['manager'], $options['labels']);

        foreach ($options as $key => $value) {
            $this->{$key} = $value;
        }
    }

    abstract public function description();

    abstract public function labels();

    public function label($name, $default = null)
    {
        $locale = $this->getCurrentLocale();

        if (! isset($this->labels[$locale])) {
            $this->labels[$locale] = $this->labels();
        }

        $key = sprintf('%s.%s', $locale, Str::camel($name));

        return Arr::get($this->labels, $key, $default);
    }

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

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

    public function isHidden()
    {
        return $this->hidden;
    }

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

    public function isHierarchical()
    {
        return $this->hierarchical;
    }

    public function rewrite($key = null, $default = null)
    {
        if (is_null($key)) {
            return $this->rewrite;
        }

        return Arr::get($this->rewrite, $key, $default);
    }

    public function slug($plural = true)
    {
        if (! $plural) {
            return Str::snake($this->name(), '-');
        }

        return $this->rewrite('slug');
    }

    protected function getCurrentLocale()
    {
        return $this->manager->getCurrentLocale();
    }
}<commit_msg>Improve the Content module<commit_after><?php

namespace Modules\Content\Platform\Types;

use Nova\Support\Arr;
use Nova\Support\Str;

use Modules\Content\Platform\ContentManager;
use Modules\Content\Platform\PostManager;


abstract class Content
{
    /**
     * @var \Modules\Content\Platform\ContentManager
     */
    protected $manager;

    /**
     * @var string
     */
    protected $name;

    /**
     * @var string
     */
    protected $model;

    /**
     * @var bool
     */
    protected $hidden = false;

    /**
     * @var bool
     */
    protected $public = true;

    /**
     * @var bool
     */
    protected $hierarchical = false;

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

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


    public function __construct(ContentManager $manager, array $options)
    {
        $this->manager = $manager;

        //
        unset($options['manager'], $options['labels']);

        foreach ($options as $key => $value) {
            $this->{$key} = $value;
        }
    }

    abstract public function description();

    abstract public function labels();

    public function label($name, $default = null)
    {
        $locale = $this->manager->getCurrentLocale();

        if (! isset($this->labels[$locale])) {
            $this->labels[$locale] = $this->labels();
        }

        $key = sprintf('%s.%s', $locale, Str::camel($name));

        return Arr::get($this->labels, $key, $default);
    }

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

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

    public function isHidden()
    {
        return $this->hidden;
    }

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

    public function isHierarchical()
    {
        return $this->hierarchical;
    }

    public function rewrite($key = null, $default = null)
    {
        if (is_null($key)) {
            return $this->rewrite;
        }

        return Arr::get($this->rewrite, $key, $default);
    }

    public function slug($plural = true)
    {
        if (! $plural) {
            return Str::snake($this->name(), '-');
        }

        return $this->rewrite('slug');
    }
}
{'fraction_non_alphanumeric': 0.15071459506279775, 'fraction_numerical': 0.0, 'mean_word_length': 1.917877447883765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '358043', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1355, 'n_words': 296}