CreateConventionalCommit   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 19
ccs 8
cts 11
cp 0.7272
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 2
A exec() 0 4 1
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
}