<commit_before><?php

namespace Thinktomorrow\Squanto\Services;

use Illuminate\Support\Arr;
use League\Flysystem\Filesystem;

class LaravelTranslationsReader
{
    /**
     * @var \Illuminate\Support\Collection
     */
    private $translations;

    /**
     * Local filesystem. Already contains the path to our translation files
     * e.g. storage/app/trans
     *
     * @var Filesystem
     */
    private $filesystem;
    private $path;

    public function __construct(Filesystem $filesystem)
    {
        $this->filesystem = $filesystem;
        $this->path = config('squanto.lang_path');
        $this->translations = collect();
    }

    /**
     * Read the lang files for a specific locale
     *
     * @param $locale
     * @param array $excluded filenames that should be excluded from the read
     * @return \Illuminate\Support\Collection
     */
    public function read($locale, array $excluded = [])
    {
        // Empty our translations for a new read
        $this->translations = collect();

        $files = $this->filesystem->listContents($locale);

        foreach ($files as $file) {
            if (in_array($file['filename'], $excluded)) {
                continue;
            }

            $this->translations[$file['filename']] = require $this->path . DIRECTORY_SEPARATOR . $file['path'];
        }

        return $this;<commit_msg>check if filename index exists<commit_after><?php

namespace Thinktomorrow\Squanto\Services;

use Illuminate\Support\Arr;
use League\Flysystem\Filesystem;

class LaravelTranslationsReader
{
    /**
     * @var \Illuminate\Support\Collection
     */
    private $translations;

    /**
     * Local filesystem. Already contains the path to our translation files
     * e.g. storage/app/trans
     *
     * @var Filesystem
     */
    private $filesystem;
    private $path;

    public function __construct(Filesystem $filesystem)
    {
        $this->filesystem = $filesystem;
        $this->path = config('squanto.lang_path');
        $this->translations = collect();
    }

    /**
     * Read the lang files for a specific locale
     *
     * @param $locale
     * @param array $excluded filenames that should be excluded from the read
     * @return \Illuminate\Support\Collection
     */
    public function read($locale, array $excluded = [])
    {
        // Empty our translations for a new read
        $this->translations = collect();

        $files = $this->filesystem->listContents($locale);

        foreach ($files as $file) {
            if (!isset($file['filename']) || in_array($file['filename'], $excluded)) {
                continue;
            }

            $this->translations[$file['filename']] = require $this->path . DIRECTORY_SEPARATOR . $file['path'];
        }

        return $this;
{'fraction_non_alphanumeric': 0.1221264367816092, 'fraction_numerical': 0.0, 'mean_word_length': 2.3839611178614826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1448250', 'n_tokens_mistral': 790, 'n_tokens_neox': 770, 'n_words': 194}