ShowCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 36
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A showCommit() 0 12 1
1
<?php
2
3
/**
4
 * GitElephant - An abstraction layer for git written in PHP
5
 * Copyright (C) 2013  Matteo Giachino
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see [http://www.gnu.org/licenses/].
19
 */
20
21
namespace GitElephant\Command;
22
23
use GitElephant\Repository;
24
25
/**
26
 * show command generator
27
 *
28
 * @author Matteo Giachino <[email protected]>
29
 */
30
class ShowCommand extends BaseCommand
31
{
32
    public const GIT_SHOW = 'show';
33
34
    /**
35
     * constructor
36
     *
37
     * @param \GitElephant\Repository $repo The repository object this command
38
     *                                      will interact with
39
     */
40 18
    public function __construct(Repository $repo = null)
41
    {
42 18
        parent::__construct($repo);
43 18
    }
44
45
    /**
46
     * build the show command
47
     *
48
     * @param string|\GitElephant\Objects\Commit $ref the reference for the show command
49
     *
50
     * @throws \RuntimeException
51
     * @return string
52
     */
53 18
    public function showCommit($ref): string
54
    {
55 18
        $this->clearAll();
56
        
57 18
        $this->addCommandName(self::GIT_SHOW);
58 18
        $this->addCommandArgument('-s');
59 18
        $this->addCommandArgument('--pretty=raw');
60 18
        $this->addCommandArgument('--no-color');
61 18
        $this->addCommandSubject($ref);
0 ignored issues
show
Bug introduced by
It seems like $ref defined by parameter $ref on line 53 can also be of type object<GitElephant\Objects\Commit>; however, GitElephant\Command\Base...nd::addCommandSubject() does only seem to accept object<GitElephant\Comma...ndCommand>|array|string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
62
63 18
        return $this->getCommand();
64
    }
65
}
66