Passed
Push — master ( fe2fa4...997733 )
by Martin
14:37
created

GitCommit::findComposer()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Scriptura\QuickStart\Tasks;
5
6
use Scriptura\QuickStart\CommandRunner;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class GitCommit
11
{
12
    /**
13
     * @var string
14
     */
15
    private $commitMessage;
16
17
    public function __construct(string $commitMessage)
18
    {
19
        $this->commitMessage = $commitMessage;
20
    }
21
22
    public function __invoke(string $name, InputInterface $input, OutputInterface $output)
23
    {
24
        $output->writeln('<info># New git commit [' . $this->commitMessage . ']...</info>');
25
26
        $directory = getcwd() . '/' . $name;
27
28
        $commands = [
29
            'git add .',
30
            'git commit -m "' . $this->commitMessage . '"',
31
        ];
32
33
        $runner = new CommandRunner($output, $directory);
34
        $isSuccessful = $runner->run($commands);
35
36
        if ($isSuccessful) {
37
            $output->writeln('<comment>Successully committed.</comment>');
38
        }
39
    }
40
}
41