<commit_before><?php

namespace allejo\stakx\Manager;

use Symfony\Component\Filesystem\Exception\FileNotFoundException;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Yaml\Yaml;

class ThemeManager extends FileManager
{
    const THEME_DEFINITION_FILE = "stakx-theme.yml";

    private $themeFolder;
    private $themeFile;
    private $themeData;

    public function __construct ($themeName, $includes = array(), $excludes = array())
    {
        parent::__construct();

        $this->themeFolder = $this->fs->appendPath("_themes", $themeName);
        $this->themeFile   = $this->fs->absolutePath($this->themeFolder, self::THEME_DEFINITION_FILE);
        $this->themeData   = array();

        if (!$this->fs->exists($this->themeFolder))
        {
            throw new FileNotFoundException("The '${themeName}' theme folder could not be found.'");
        }

        if ($this->fs->exists($this->themeFile))
        {
            $this->themeData = Yaml::parse(file_get_contents($this->themeFile));
        }

        foreach ($this->themeData['include'] as &$include)<commit_msg>Don't crash when theme file doesn't have excludes/includes specified<commit_after><?php

namespace allejo\stakx\Manager;

use Symfony\Component\Filesystem\Exception\FileNotFoundException;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Yaml\Yaml;

class ThemeManager extends FileManager
{
    const THEME_DEFINITION_FILE = "stakx-theme.yml";

    private $themeFolder;
    private $themeFile;
    private $themeData;

    public function __construct ($themeName, $includes = array(), $excludes = array())
    {
        parent::__construct();

        $this->themeFolder = $this->fs->appendPath("_themes", $themeName);
        $this->themeFile   = $this->fs->absolutePath($this->themeFolder, self::THEME_DEFINITION_FILE);
        $this->themeData   = array(
            'exclude' => array(),
            'include'  => array()
        );

        if (!$this->fs->exists($this->themeFolder))
        {
            throw new FileNotFoundException("The '${themeName}' theme folder could not be found.'");
        }

        if ($this->fs->exists($this->themeFile))
        {
            $themeData = Yaml::parse(file_get_contents($this->themeFile));

            $this->themeData = array_merge_recursive($this->themeData, $themeData);
        }

        foreach ($this->themeData['include'] as &$include)
{'fraction_non_alphanumeric': 0.1430343116990492, 'fraction_numerical': 0.0, 'mean_word_length': 3.230769230769231, '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': '1049940', 'n_tokens_mistral': 717, 'n_tokens_neox': 689, 'n_words': 132}