Issues (8)

src/Commands/ValidateCommand.php (1 issue)

1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerChangelogs\Commands;
7
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
use Vaimo\ComposerChangelogs\Factories;
12
13
class ValidateCommand extends \Composer\Command\BaseCommand
14
{
15
    protected function configure()
16
    {
17
        $this->setName('changelog:validate');
18
19
        $this->setDescription('Validate package changelog markup and structure');
20
21
        $this->addArgument(
22
            'name',
23
            \Symfony\Component\Console\Input\InputArgument::OPTIONAL,
24
            'Targeted package name. Default: root package'
25
        );
26
27
        $this->addOption(
28
            '--from-source',
29
            null,
30
            \Symfony\Component\Console\Input\InputOption::VALUE_NONE,
31
            'Extract configuration from vendor package instead of using global installation data'
32
        );
33
    }
34
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $packageName = $input->getArgument('name');
38
        $fromSource = $input->getOption('from-source');
39
40
        $composerCtxFactory = new \Vaimo\ComposerChangelogs\Factories\ComposerContextFactory(
41
            $this->getComposer()
0 ignored issues
show
Deprecated Code introduced by
The function Composer\Command\BaseCommand::getComposer() has been deprecated: since Composer 2.3.0 use requireComposer or tryComposer depending on whether you have $required set to true or false ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

41
            /** @scrutinizer ignore-deprecated */ $this->getComposer()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
42
        );
43
44
        $composerCtx = $composerCtxFactory->create();
45
        
46
        $chLogRepoFactory = new Factories\ChangelogRepositoryFactory($composerCtx, $output);
47
        $chLogRepo = $chLogRepoFactory->create($fromSource);
48
49
        $changelog = $chLogRepo->getByPackageName(
50
            $packageName,
51
            $output->getVerbosity()
52
        );
53
        
54
        return (int)($changelog === null);
55
    }
56
}
57