Completed
Push — master ( f0c745...274b6a )
by Sergi Tur
01:40
created

getRepoFromGithubConfig()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 8
Ratio 50 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 4
nop 0
dl 8
loc 16
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace Acacha\ForgePublish\Commands\Traits;
4
5
/**
6
 * Trait InteractsWithLocalGithub.
7
 *
8
 * @package Acacha\ForgePublish\Commands\Traits
9
 */
10
trait InteractsWithLocalGithub
11
{
12
    /**
13
     * Get github repo from github.
14
     *
15
     * @return string
16
     */
17
    protected function getRepoFromGithubConfig()
18
    {
19
        $remote = `git remote get-url origin 2> /dev/null`;
20
        if (! starts_with($remote, ['[email protected]:','https://github.com/'])) {
21
            return '';
22
        }
23
24 View Code Duplication
        if (starts_with($remote, '[email protected]:')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
            // [email protected]:acacha/forge-publish.git
26
            return explode('.', explode(":", $remote)[1])[0];
27
        }
28 View Code Duplication
        if (starts_with($remote, 'https://github.com/')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
//            https://github.com/acacha/llum.git
30
            return explode('.', str_replace('https://github.com/', '', $remote))[0];
31
        }
32
    }
33
}