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.

NewProjectCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 46
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 17 1
A doExecute() 0 18 2
1
<?php
2
namespace Kunstmaan\Skylab\Command;
3
4
use RuntimeException;
5
use Symfony\Component\Console\Input\InputArgument;
6
7
/**
8
 * NewProjectCommand
9
 */
10
class NewProjectCommand extends AbstractCommand
11
{
12
13
    /**
14
     * Configures the current command.
15
     */
16
    protected function configure()
17
    {
18
        $this
19
            ->addDefaults()
20
            ->setName('new')
21
            ->setDescription('Create a new Skylab project')
22
            ->addArgument('name', InputArgument::OPTIONAL, 'The name of the project. All lowercase, no spaces or special characters. Keep it short, yet descriptive')
23
            ->setHelp(<<<EOT
24
The <info>new</info> command creates a new project. It will setup the directory structure and apply the "base" skeleton
25
which is responsible for setting up users, permissions and ownership.
26
27
<info>php skylab.phar new</info>
28
<info>php skylab.phar new testproject</info>
29
30
EOT
31
            );
32
    }
33
34
    /**
35
     * @throws \RuntimeException
36
     */
37
    protected function doExecute()
38
    {
39
        $projectname = $this->dialogProvider->askFor("Please enter the name of the project. All lowercase, no spaces or special characters. Keep it short, yet descriptive", 'name');
40
        $this->dialogProvider->logStep("Creating project $projectname");
41
        // Check if the project exists, do use in creating a new one with the same name.
42
        if ($this->fileSystemProvider->projectExists($projectname)) {
43
            $this->dialogProvider->logError("A project with name $projectname already exists!", false);
44
        } else {
45
            $this->dialogProvider->logTask("Creating project directory for $projectname");
46
            $this->fileSystemProvider->createProjectDirectory($projectname);
47
        }
48
        $project = new \ArrayObject();
49
        $project["name"] = $projectname;
50
        $project["dir"] = $this->fileSystemProvider->getProjectDirectory($projectname);
51
        $this->skeletonProvider->applySkeleton($project, $this->skeletonProvider->findSkeleton("base"));
52
        $this->projectConfigProvider->writeProjectConfig($project);
53
54
    }
55
}
56