Completed
Push — master ( 9017a1...3ff80b )
by Tomáš
04:23
created

GihubPublishingProcess   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 78.56%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 35
ccs 11
cts 14
cp 0.7856
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A pushDirectoryContentToRepository() 0 22 2
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 GitWrapper\GitWrapper;
13
use Symplify\PHP7_Sculpin\Utils\FilesystemChecker;
14
15
final class GihubPublishingProcess
16
{
17
    /**
18
     * @var string
19
     */
20
    const CONFIG_EMAIL = '[email protected]';
21
22
    /**
23
     * @var string
24
     */
25
    const CONFIG_NAME = 'Travis';
26
27 2
    public function pushDirectoryContentToRepository(string $outputDirectory, string $githubRepository)
28
    {
29 2
        FilesystemChecker::ensureDirectoryExists($outputDirectory);
30
31 1
        $git = (new GitWrapper())->init($outputDirectory);
32
33 1
        if (getenv('TRAVIS')) {
34 1
            $git->config('user.email', self::CONFIG_EMAIL);
35 1
            $git->config('user.name', self::CONFIG_NAME);
36
        }
37
38 1
        $git->checkout('gh-pages', [
39 1
            'orphan' => true,
40
        ]);
41 1
        $git->add('.');
42 1
        $git->commit('Regenerate output');
43 1
        $git->addRemote('origin', $githubRepository);
44
        $git->push('origin', 'gh-pages', [
45
            'force' => true,
46
            'quiet' => true,
47
        ]);
48
    }
49
}
50