<commit_before><?php

namespace Nova\Plugin\Console;

use Nova\Console\Command;
use Nova\Plugin\PluginManager;


class PluginListCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'plugin:list';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'List all application plugins';

    /**
     * @var \Nova\Plugin\PluginManager
     */
    protected $plugins;

    /**
     * The table headers for the command.
     *
     * @var array
     */
    protected $headers = ['#', 'Package', 'Slug', 'Config Files', 'Translations', 'Location'];

    /**
     * Create a new command instance.
     *
     * @param \Nova\Plugin\PluginManager $plugin
     */
    public function __construct(PluginManager $plugins)
    {
        parent::__construct();

        $this->plugins = $plugins;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        $plugins = $this->plugins->all()->where('theme', true);

        if ($plugins->isEmpty()) {
            return $this->error("Your application doesn't have any plugins.");
        }

        $this->displayPlugins($this->getPlugins());
    }

    /**
     * Get all plugins.
     *
     * @return array
     */
    protected function getPlugins()
    {
        $plugins = $this->plugins->all()->where('theme', false);

        $results = array();

        //
        $count = 1;

        foreach ($plugins as $plugin) {
            $results[] = $this->getPluginInformation($plugin, $count);

            $count++;
        }

        return array_filter($results);
    }

    /**
     * Returns plugin manifest information.
     *
     * @param string $plugin
     *
     * @return array
     */
    protected function getPluginInformation($plugin, $count)
    {
        $config   = $plugin['path'] .'Config';
        $language = $plugin['path'] .'Language';

        if ($plugin['location'] === 'local') {
            $location = 'Local';
        } else {
            $location = 'Vendor';
        }

        return array(
            'id'       => $count,
            'name'     => $plugin['name'],
            'slug'     => $plugin['slug'],
            'config'   => is_dir($config)   ? 'Yes' : 'No',
            'language' => is_dir($language) ? 'Yes' : 'No',
            'location' => $location,
        );
    }

    /**
     * Display the plugin information on the console.
     *
     * @param array $plugins
     */
    protected function displayPlugins(array $plugins)
    {
        $this->table($this->headers, $plugins);
    }
}
<commit_msg>Improve the Nova\Plugin\Console\PluginListCommand<commit_after><?php

namespace Nova\Plugin\Console;

use Nova\Console\Command;
use Nova\Plugin\PluginManager;


class PluginListCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'plugin:list';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'List all application plugins';

    /**
     * @var \Nova\Plugin\PluginManager
     */
    protected $plugins;

    /**
     * The table headers for the command.
     *
     * @var array
     */
    protected $headers = ['#', 'Package', 'Slug', 'Config Files', 'Translations', 'Location'];

    /**
     * Create a new command instance.
     *
     * @param \Nova\Plugin\PluginManager $plugin
     */
    public function __construct(PluginManager $plugins)
    {
        parent::__construct();

        $this->plugins = $plugins;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        $plugins = $this->plugins->all()->where('theme', false);

        if ($plugins->isEmpty()) {
            return $this->error("Your application doesn't have any plugins.");
        }

        $this->displayPlugins($this->getPlugins());
    }

    /**
     * Get all plugins.
     *
     * @return array
     */
    protected function getPlugins()
    {
        $plugins = $this->plugins->all()->where('theme', false);

        $results = array();

        //
        $count = 1;

        foreach ($plugins as $plugin) {
            $results[] = $this->getPluginInformation($plugin, $count);

            $count++;
        }

        return array_filter($results);
    }

    /**
     * Returns plugin manifest information.
     *
     * @param string $plugin
     *
     * @return array
     */
    protected function getPluginInformation($plugin, $count)
    {
        $config   = $plugin['path'] .'Config';
        $language = $plugin['path'] .'Language';

        if ($plugin['location'] === 'local') {
            $location = 'Local';
        } else {
            $location = 'Vendor';
        }

        return array(
            'id'       => $count,
            'name'     => $plugin['name'],
            'slug'     => $plugin['slug'],
            'config'   => is_dir($config)   ? 'Yes' : 'No',
            'language' => is_dir($language) ? 'Yes' : 'No',
            'location' => $location,
        );
    }

    /**
     * Display the plugin information on the console.
     *
     * @param array $plugins
     */
    protected function displayPlugins(array $plugins)
    {
        $this->table($this->headers, $plugins);
    }
}

{'fraction_non_alphanumeric': 0.1520413818584888, 'fraction_numerical': 0.0003694808793644929, 'mean_word_length': 1.8168574401664932, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '6426226', 'n_tokens_mistral': 1557, 'n_tokens_neox': 1517, 'n_words': 352}