GitTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 32
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A gitInit() 0 4 2
A gitCommitUpdateDependecies() 0 4 2
A gitInstalled() 0 3 1
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