Completed
Push — master ( a8bbce...8295bf )
by Tomáš
05:19 queued 02:59
created

GihubPublishingProcess   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 21
rs 10
c 0
b 0
f 0
ccs 0
cts 12
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setupTravisIdentityToGit() 0 7 2
A addAndPushContentToGithubRepository() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify
7
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
8
 */
9
10
namespace Symplify\PHP7_Sculpin\Github;
11
12
use Symfony\Component\Process\Process;
13
14
final class GihubPublishingProcess
15
{
16
    public function setupTravisIdentityToGit()
17
    {
18
        if (getenv('TRAVIS')) {
19
            (new Process('git config user.email "[email protected]"'))->run();
20
            (new Process('git config user.name "Travis"'))->run();
21
        }
22
    }
23
24
    public function addAndPushContentToGithubRepository(string $outputDirectory, string $githubRepository)
25
    {
26
        (new Process(sprintf('cd %s', $outputDirectory)))->run();
27
        (new Process('git init && git add . && git commit -m "Regenerate output"'))->run();
28
29
        (new Process(sprintf(
30
            'git push --force --quiet "${%s}" master:gh-pages > /dev/null 2>&1',
31
            $githubRepository
32
        )))->run();
33
    }
34
}
35