* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Thanks\Command; use Composer\Command\BaseCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Thanks\GitHubClient; /** * @author Nicolas Grekas
*/
class FundCommand extends BaseCommand
{
private $star = '★ ';
private $love = '💖 ';
private $cash = '💵 ';
protected function configure()
{
if ('Hyper' === getenv('TERM_PROGRAM')) {
$this->star = '⭐ ';
} elseif ('\\' === \DIRECTORY_SEPARATOR) {
$this->star = '*';
$this->love = '<3';
$this->cash = '$$$';
}
$this->setName('fund')
->setDescription(sprintf('Discover the funding links that fellow PHP package maintainers publish %s.', $this->cash))
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$gitHub = new GitHubClient($composer, $this->getIO());
$repos = $gitHub->getRepositories($failures, true);
$fundings = [];
$notStarred = 0;
foreach ($repos as $alias => $repo) {
$notStarred += (int) !$repo['viewerHasStarred'];
foreach ($repo['fundingLinks'] as $link) {
list($owner, $package) = explode('/', $repo['package'], 2);
$fundings[$owner][$link['url']][] = $package;
}
}
if ($fundings) {
$prev = null;
$output->writeln('The following packages were found in your dependencies and publish sponsoring links on their GitHub page:');
foreach ($fundings as $owner => $links) {
$output->writeln(sprintf("\n