0 follower

Final Class Yiisoft\YiiDevTool\App\Command\Stats\ContributorsCommand

InheritanceYiisoft\YiiDevTool\App\Command\Stats\ContributorsCommand » Symfony\Component\Console\Command\Command

Method Details

Hide inherited methods

configure() protected method

protected mixed configure ( )

                protected function configure()
{
    $this
        ->setName('stats/contributors')
        ->addOption('since', null, InputArgument::OPTIONAL, 'Date and time to check contributors from YYYY-MM-DD.')
        ->setDescription('Displays contributors statistics');
    parent::configure();
}

            
execute() protected method

protected mixed execute ( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output )
$input \Symfony\Component\Console\Input\InputInterface
$output \Symfony\Component\Console\Output\OutputInterface

                protected function execute(InputInterface $input, OutputInterface $output)
{
    $since = $input->getOption('since');
    $sinceCommand = '';
    if (!empty($since)) {
        $sinceCommand = " --since=$since";
    }
    $this->initPackageList();
    $installedPackages = $this
        ->getPackageList()
        ->getInstalledAndEnabledPackages();
    $contributors = [];
    foreach ($installedPackages as $installedPackage) {
        $git = $installedPackage
            ->getGitWorkingCopy()
            ->getWrapper();
        $out = $git->git("shortlog -s -e --group=author --group=trailer:co-authored-by$sinceCommand HEAD", $installedPackage->getPath());
        foreach (preg_split('~\R~', $out, -1, PREG_SPLIT_NO_EMPTY) as $line) {
            [$commits, $name] = preg_split('~\t~', $line, -1, PREG_SPLIT_NO_EMPTY);
            if (array_key_exists($name, $contributors)) {
                $contributors[$name] += (int)$commits;
            } else {
                $contributors[$name] = (int)$commits;
            }
        }
    }
    arsort($contributors);
    foreach ($contributors as $name => $commits) {
        echo $name . "\n";
    }
    return Command::SUCCESS;
}

            
getAppRootDir() protected method

Use this method to get a root directory of the tool.

Commands and components can be moved as a result of refactoring, so you should not rely on their location in the file system.

protected string getAppRootDir ( )
return string

Path to the root directory of the tool WITH a TRAILING SLASH.

                protected function getAppRootDir(): string
{
    return rtrim($this
            ->getApplication()
            ->getRootDir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}

            
getIO() protected method

protected Yiisoft\YiiDevTool\App\Component\Console\OutputManager getIO ( )

                protected function getIO(): OutputManager
{
    if ($this->io === null) {
        throw new RuntimeException('IO is not initialized.');
    }
    return $this->io;
}

            
initialize() protected method

protected mixed initialize ( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output )
$input \Symfony\Component\Console\Input\InputInterface
$output \Symfony\Component\Console\Output\OutputInterface

                protected function initialize(InputInterface $input, OutputInterface $output)
{
    $this->io = new OutputManager(new YiiDevToolStyle($input, $output));
}