AddProjectCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 79
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 *
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Commands\Project;
13
14 View Code Duplication
final class AddProjectCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
15
{
16
    /**
17
     * The project name.
18
     *
19
     * @var string
20
     */
21
    public $name;
22
23
    /**
24
     * The project description.
25
     *
26
     * @var string
27
     */
28
    public $description;
29
30
    /**
31
     * The project visibility_level.
32
     *
33
     * @var int
34
     */
35
    public $visibility_level;
36
37
    /**
38
     * The project slug.
39
     *
40
     * @var string
41
     */
42
    public $path;
43
44
    /**
45
     * The project creator id.
46
     *
47
     * @var int
48
     */
49
    public $creator_id;
50
51
    /**
52
     * The project ower.
53
     *
54
     * @var int
55
     */
56
    public $owner_id;
57
58
    /**
59
     * The validation rules.
60
     *
61
     * @var string[]
62
     */
63
    public $rules = [
64
        'name' => 'required|string',
65
        'description' => 'string',
66
        'visibility_level' => 'int|min:1|max:4',
67
        'path' => 'required|string',
68
        'creator_id' => 'int',
69
        'owner_id' => 'int',
70
    ];
71
72
    /**
73
     * Create a new add project command instance.
74
     *
75
     * @param string $name
76
     * @param string $description
77
     * @param int    $visibility_level
78
     * @param string $path
79
     * @param int    $creator_id
80
     * @param int    $owner_id
81
     * @param bool   $issues_enabled
0 ignored issues
show
Bug introduced by
There is no parameter named $issues_enabled. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
82
     */
83
    public function __construct($name, $description, $visibility_level, $path, $creator_id, $owner_id)
84
    {
85
        $this->name = $name;
86
        $this->description = $description;
87
        $this->visibility_level = (int) $visibility_level;
88
        $this->path = $path;
89
        $this->creator_id = $creator_id;
90
        $this->owner_id = $owner_id;
91
    }
92
}
93