<commit_before><?php

namespace Sven\FlexEnv\Commands;

use Illuminate\Support\Collection;

class ListEnv extends EnvCommand
{
    /** @var string */
    protected $name = 'env:list';

    /** @var string */
    protected $description = 'Shows all the current entries in your .env file';

    public function handle(): int
    {
        $config = $this->config();

        $data = Collection::make($config->all())
            ->reject(function ($value, $key) {
                return $value === '' || ! is_string($key);
            });

        $this->table(['Key', 'Value'], $data);

        return 0;
    }
}
<commit_msg>Map to array in env:list, add -r option<commit_after><?php

namespace Sven\FlexEnv\Commands;

use Illuminate\Support\Collection;
use Sven\FileConfig\Store;
use Symfony\Component\Console\Input\InputOption;

class ListEnv extends EnvCommand
{
    /** @var string */
    protected $name = 'env:list';

    /** @var string */
    protected $description = 'Shows all the current entries in your .env file';

    public function handle(): int
    {
        $config = $this->config();

        $data = Collection::make($config->all())
            ->reject(function ($value, $key) {
                return $value === '' || ! is_string($key);
            })
            ->when($this->option('resolve-references'), $this->resolveReferences($config))
            ->map(function ($value, $key) {
                return [$key, $value];
            });

        $this->table(['Key', 'Value'], $data);

        return 0;
    }

    protected function getOptions()
    {
        return [
            ['resolve-references', 'r', InputOption::VALUE_NONE, 'Should references in the .env file be resolved?'],
        ];
    }

    protected function resolveReferences(Store $config): \Closure
    {
        return function (Collection $data) use ($config) {
            return $data->map(function ($value) use ($config) {
                preg_match('/\$\{(.+)\}/', $value, $matches);

                if (isset($matches[1])) {
                    return $config->get($matches[1]);
                }

                return $value;
            });
        };
    }
}

{'fraction_non_alphanumeric': 0.15952051636698938, 'fraction_numerical': 0.0018441678192715537, 'mean_word_length': 2.104434907010014, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '5415504', 'n_tokens_mistral': 618, 'n_tokens_neox': 595, 'n_words': 151}