CreateConventionalCommit::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 4
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 2
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damianopetrungaro\PHPCommitizen;
6
7
use Damianopetrungaro\PHPCommitizen\Section\Body;
8
use Damianopetrungaro\PHPCommitizen\Section\Footer;
9
use Damianopetrungaro\PHPCommitizen\Section\Subject;
10
use function exec;
11
use function var_dump;
12
13
class CreateConventionalCommit
14
{
15 2
    public function __invoke(Subject $subject, Body $body, Footer $footer, bool $addAllToStage): void
16
    {
17 2
        if ($addAllToStage) {
18 1
            $this->exec('git add .');
19
        }
20
21 2
        $safeSubject = escapeshellarg((string)$subject);
22 2
        $safeBody = escapeshellarg((string)$body);
23 2
        $safeFooter = escapeshellarg((string)$footer);
24 2
        $this->exec("git commit -m $safeSubject -m $safeBody -m $safeFooter");
25 2
    }
26
27
    protected function exec(string $command): void
28
    {
29
        exec($command);
30
    }
31
}