Read::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 6
c 1
b 0
f 1
nc 2
nop 2
dl 0
loc 9
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace aspirantzhang\octopusRevision\command;
6
7
use think\console\Command;
8
use think\console\Input;
9
use think\console\input\Argument;
10
use think\console\Output;
11
use aspirantzhang\octopusRevision\RevisionAPI;
12
13
class Read extends Command
14
{
15
    protected function configure()
16
    {
17
        $this->setName('revision:read')
18
        ->addArgument('revisionId', Argument::REQUIRED, "Revision id")
19
        ->setDescription('View the details of a revision');
20
    }
21
22
    protected function execute(Input $input, Output $output)
23
    {
24
        $revisionId = trim($input->getArgument('revisionId'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('revisionId') can also be of type think\console\input\Argument; however, parameter $string of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

24
        $revisionId = trim(/** @scrutinizer ignore-type */ $input->getArgument('revisionId'));
Loading history...
25
26
        $result = (new RevisionAPI())->readAPI((int)$revisionId);
27
        if ($result['success'] === true) {
28
            $output->writeln('<comment>' . print_r($result['data']['dataSource']) . '</comment>');
0 ignored issues
show
Bug introduced by
Are you sure print_r($result['data']['dataSource']) of type string|true can be used in concatenation? ( Ignorable by Annotation )

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

28
            $output->writeln('<comment>' . /** @scrutinizer ignore-type */ print_r($result['data']['dataSource']) . '</comment>');
Loading history...
29
        } else {
30
            $output->writeln('<error>' . $result['message'] . '</error>');
31
        }
32
    }
33
}
34