<commit_before><?php
/**
 * System Controller
 */
namespace App\System;

use App\Downloader;
use League\Flysystem\Filesystem;

/**
 * Class Controller
 * @package App\System
 */
class Controller
{
    /**
     * Flysystem lib
     * @var Filesystem
     */
    private $system;

    /**
     * Receives dependencies
     * @param Filesystem $system
     */
    public function __construct(Filesystem $system)
    {
        $this->system = $system;
    }

    /**
     * Gets the array of the local lessons & series.
     *
     * @return array
     */
    public function getAllLessons()
    {
        $array = [];
        $array['lessons'] = $this->getLessons();
        $array['series'] = $this->getSeries();

        Downloader::$currentLessonNumber = count($array['lessons']);

        return $array;
    }

    /**
     * Get the series
     * @return array
     */
    private function getSeries()
    {
        $list = $this->system->listContents(SERIES_FOLDER, true);
        $array = [];

        foreach ($list as $entry) {
            if ($entry['type'] != 'file') {
                continue;
            } //skip folder, we only want the files

            $serie = substr($entry['dirname'], strpos($entry['dirname'], '\\') + 1);
            $episode = (int) substr($entry['filename'], 0, strpos($entry['filename'], '-'));

            $array[$serie][] = $episode;
        }

        return $array;
    }

    /**
     * Gets the lessons in the folder.
     *
     * @return array
     */
    public function getLessons()
    {
        $list = $this->system->listContents(LESSONS_FOLDER);
        $array = [];<commit_msg>Fixed a bug on saving series in unix systems, thanks to <NAME><commit_after><?php
/**
 * System Controller
 */
namespace App\System;

use App\Downloader;
use League\Flysystem\Filesystem;

/**
 * Class Controller
 * @package App\System
 */
class Controller
{
    /**
     * Flysystem lib
     * @var Filesystem
     */
    private $system;

    /**
     * Receives dependencies
     * @param Filesystem $system
     */
    public function __construct(Filesystem $system)
    {
        $this->system = $system;
    }

    /**
     * Gets the array of the local lessons & series.
     *
     * @return array
     */
    public function getAllLessons()
    {
        $array = [];
        $array['lessons'] = $this->getLessons();
        $array['series'] = $this->getSeries();

        Downloader::$currentLessonNumber = count($array['lessons']);

        return $array;
    }

    /**
     * Get the series
     * @return array
     */
    private function getSeries()
    {
        $list = $this->system->listContents(SERIES_FOLDER, true);
        $array = [];

        foreach ($list as $entry) {
            if ($entry['type'] != 'file') {
                continue;
            } //skip folder, we only want the files

            $serie = substr($entry['dirname'], strpos($entry['dirname'], DIRECTORY_SEPARATOR) + 1);
            $episode = (int) substr($entry['filename'], 0, strpos($entry['filename'], '-'));

            $array[$serie][] = $episode;
        }

        return $array;
    }

    /**
     * Gets the lessons in the folder.
     *
     * @return array
     */
    public function getLessons()
    {
        $list = $this->system->listContents(LESSONS_FOLDER);
        $array = [];
{'fraction_non_alphanumeric': 0.15285285285285286, 'fraction_numerical': 0.0012012012012012011, 'mean_word_length': 1.995503597122302, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3678408', 'n_tokens_mistral': 998, 'n_tokens_neox': 972, 'n_words': 228}