<commit_before><?php
declare(strict_types = 1);
/**
 * /src/Command/Utils/CheckVendorDependencies.php
 *
 * @author  TLe, <NAME> <<EMAIL>>
 */

namespace App\Command\Utils;

use App\Command\Traits\SymfonyStyleTrait;
use InvalidArgumentException;
use LogicException;
use RuntimeException;
use SplFileInfo;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process;
use function array_map;
use function array_unshift;
use function basename;
use function count;
use function implode;
use function iterator_to_array;
use function preg_match_all;
use function sort;
use function sprintf;
use function str_replace;

/**
 * Class CheckVendorDependencies
 *
 * @package App\Command\Utils
 * @author  TLe, <NAME> <<EMAIL>>
 */
class CheckVendorDependencies extends Command
{
    // Traits
    use SymfonyStyleTrait;

    /**
     * @var string
     */
    private $projectDir;

    /**
     * @var \Symfony\Component\Console\Style\SymfonyStyle
     */
    private $io;

    /**
     * CheckVendorDependencies constructor.
     *
     * @param string $projectDir
     *
     * @throws \Symfony\Component\Console\Exception\LogicException
     */
    public function __construct(string $projectDir)
    {
        parent::__construct('check-vendor-dependencies');

        $this->setDescription('Console command to check vendor dependencies for bin');

        $this->projectDir = $projectDir;
    }

    /** @noinspection PhpMissingParentCallCommonInspection */
    /**
     * Executes the current command.
     *
     * @param \Symfony\Component\Console\Input\InputInterface   $input
     * @param \Symfony\Component\Console\Output\OutputInterface $output
     *
     * @return int|null
     *
     * @throws InvalidArgumentException
     * @throws LogicException
     * @throws RuntimeException
     * @throws \Symfony\Component\Process\Exception\RuntimeException
     * @throws \Symfony\Component\Process\Exception\LogicException
     */
    protected function execute(InputInterface $input, OutputInterface $output): ?int
    {
        $this->io = $this->getSymfonyStyle($input, $output);

        $directories = $this->getNamespaceDirectories();

        array_unshift($directories, $this->projectDir);

        $progressBar = $this->getProgressBar(count($directories), 'Checking all vendor dependencies');
        $output = [];

        $bar = function (string $path) use ($progressBar, &$output): void {
            $process = $this->processNamespacePath($path);

            if (!empty($process)) {
                $libraries = $this->parseLibraries($process);

                foreach ($libraries as $row => $data) {
                    $title = '';
                    $relativePath = '';

                    if ($row === 0) {
                        $title = basename($path);
                        $relativePath = str_replace($this->projectDir, '', $path) . '/composer.json';
                    }

                    $output[] = [
                        $title,
                        $relativePath,
                        $data[1],
                        $data[4],
                        $data[2],
                        $data[3],
                    ];
                }
            }

            $progressBar->advance();
        };

        //$this->io->section('Starting to check vendor-bin dependencies');

        array_map($bar, $directories);

        $headers = [
            'Namespace',
            'Path',
            'Dependency',
            'Description',
            'Current version',
            'Available version'
        ];

        $this->io->table($headers, $output);

        return null;<commit_msg>refactor: removed dead code<commit_after><?php
declare(strict_types = 1);
/**
 * /src/Command/Utils/CheckVendorDependencies.php
 *
 * @author  TLe, <NAME> <<EMAIL>>
 */

namespace App\Command\Utils;

use App\Command\Traits\SymfonyStyleTrait;
use InvalidArgumentException;
use LogicException;
use RuntimeException;
use SplFileInfo;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process;
use function array_map;
use function array_unshift;
use function basename;
use function count;
use function implode;
use function iterator_to_array;
use function preg_match_all;
use function sort;
use function sprintf;
use function str_replace;

/**
 * Class CheckVendorDependencies
 *
 * @package App\Command\Utils
 * @author  TLe, <NAME> <<EMAIL>>
 */
class CheckVendorDependencies extends Command
{
    // Traits
    use SymfonyStyleTrait;

    /**
     * @var string
     */
    private $projectDir;

    /**
     * @var \Symfony\Component\Console\Style\SymfonyStyle
     */
    private $io;

    /**
     * CheckVendorDependencies constructor.
     *
     * @param string $projectDir
     *
     * @throws \Symfony\Component\Console\Exception\LogicException
     */
    public function __construct(string $projectDir)
    {
        parent::__construct('check-vendor-dependencies');

        $this->setDescription('Console command to check vendor dependencies for bin');

        $this->projectDir = $projectDir;
    }

    /** @noinspection PhpMissingParentCallCommonInspection */
    /**
     * Executes the current command.
     *
     * @param \Symfony\Component\Console\Input\InputInterface   $input
     * @param \Symfony\Component\Console\Output\OutputInterface $output
     *
     * @return int|null
     *
     * @throws InvalidArgumentException
     * @throws LogicException
     * @throws RuntimeException
     * @throws \Symfony\Component\Process\Exception\RuntimeException
     * @throws \Symfony\Component\Process\Exception\LogicException
     */
    protected function execute(InputInterface $input, OutputInterface $output): ?int
    {
        $this->io = $this->getSymfonyStyle($input, $output);

        $directories = $this->getNamespaceDirectories();

        array_unshift($directories, $this->projectDir);

        $progressBar = $this->getProgressBar(count($directories), 'Checking all vendor dependencies');
        $output = [];

        $bar = function (string $path) use ($progressBar, &$output): void {
            $process = $this->processNamespacePath($path);

            if (!empty($process)) {
                $libraries = $this->parseLibraries($process);

                foreach ($libraries as $row => $data) {
                    $title = '';
                    $relativePath = '';

                    if ($row === 0) {
                        $title = basename($path);
                        $relativePath = str_replace($this->projectDir, '', $path) . '/composer.json';
                    }

                    $output[] = [
                        $title,
                        $relativePath,
                        $data[1],
                        $data[4],
                        $data[2],
                        $data[3],
                    ];
                }
            }

            $progressBar->advance();
        };

        array_map($bar, $directories);

        $headers = [
            'Namespace',
            'Path',
            'Dependency',
            'Description',
            'Current version',
            'Available version'
        ];

        $this->io->table($headers, $output);

        return null;
{'fraction_non_alphanumeric': 0.1192468619246862, 'fraction_numerical': 0.0015690376569037657, 'mean_word_length': 2.185755935027072, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 45, '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': '2641850', 'n_tokens_mistral': 2090, 'n_tokens_neox': 1994, 'n_words': 417}