Passed
Branch master (655a42)
by Allan
03:27 queued 01:16
created

ValidateCommand::printException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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
        $chLogRepoFactory = new Factories\ChangelogRepositoryFactory($this->getComposer(), $output);
0 ignored issues
show
Bug introduced by
The type Vaimo\ComposerChangelogs...ngelogRepositoryFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
41
        $chLogRepo = $chLogRepoFactory->create($fromSource);
42
43
        $changelog = $chLogRepo->getByPackageName(
44
            $packageName,
45
            $output->getVerbosity()
46
        );
47
        
48
        return (int)($changelog === null);
49
    }
50
}
51