GitTrait::gitInstalled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace CleaniqueCoders\Console\Traits;
4
5
trait GitTrait
6
{
7
    /**
8
     * Initiliase git repository.
9
     *
10
     * @return void
11
     */
12
    public function gitInit()
13
    {
14
        if ($this->gitInstalled()) {
15
            exec('git init && git add . && git commit -m "Initial Commits"');
16
        }
17
    }
18
19
    /**
20
     * Commit composer.lock on update dependencies.
21
     *
22
     * @return void
23
     */
24
    public function gitCommitUpdateDependecies()
25
    {
26
        if ($this->gitInstalled()) {
27
            exec('git add composer.lock && git commit -m "Upadate dependencies"');
28
        }
29
    }
30
31
    /**
32
     * Check if git is installed.
33
     */
34
    public function gitInstalled(): bool
35
    {
36
        return ! empty(exec('which git'));
37
    }
38
}
39