GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ShareCommand   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
lcom 1
cbo 5
dl 0
loc 56
rs 10
c 1
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A doExecute() 0 15 3
A configure() 0 14 1
A getIP() 0 15 3
1
<?php
2
3
namespace Kunstmaan\Skylab\Command;
4
5
6
class ShareCommand extends AbstractCommand
7
{
8
9
    /**
10
     * Configures the current command.
11
     */
12
    protected function configure()
13
    {
14
        $this
15
            ->addDefaults()
16
            ->setName('share')
17
            ->setDescription('Get a full table of all your projects with the xip.io url')
18
            ->setHelp(<<<EOT
19
The <info>share</info> command shows a table of all your locally installed projects together with the xip.io url.
20
21
<info>php skylab.phar share</info>                         # Will show the xip.io table
22
23
EOT
24
            );
25
    }
26
27
    /**
28
     * @throws \RuntimeException
29
     */
30
    protected function doExecute()
31
    {
32
        if(!$this->app["config"]["develmode"]) {
33
           $this->dialogProvider->logWarning('develmode=false, You do not have xip.io urls when your develmode is set to false');
34
           return;
35
        }
36
        $rows = array();
37
        $ip = $this->getIP();
38
        $projects = $this->fileSystemProvider->getProjects();
39
        foreach($projects as $key => $projectFile) {
40
            $projectname = $projectFile->getFilename();
41
            $rows[] = array($projectname, 'http://'.$projectname.'.'.$ip.'.xip.io');
42
        }
43
        $this->dialogProvider->renderTable(array('Project', 'URL'), $rows);
44
    }
45
46
    private function getIP() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
47
        $os = strtolower(PHP_OS);
48
        switch ($os) {
49
            case 'linux': //Linux
50
                preg_match_all('/inet addr: ?([^ ]+)/', `ifconfig |grep "inet " |grep -v "127.0.0.1"`, $ips);
51
                break;
52
            case 'darwin': //OSX
53
                preg_match_all('/inet ?([^ ]+)/', `ifconfig -au |grep "inet " |grep -v "127.0.0.1"`, $ips);
54
                break;
55
            default:
56
                throw new \Exception("Unsupported OS: " . $os);
57
                break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
58
        }
59
        return $ips[1][0];
60
    }
61
}
62