Completed
Push — master ( 2be7a2...baa265 )
by Mario
03:01
created

WorkspaceProjects   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 10 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 5 22 4

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
namespace Marek\Toggable\API\Http\Request\Workspace;
4
5
/**
6
 * Class WorkspaceProjects
7
 * @package Marek\Toggable\API\Http\Request\Workspace
8
 *
9
 * @property-read boolean $active
10
 * @property-read boolean $actualHours
11
 * @property-read boolean $onlyTemplates
12
 */
13
class WorkspaceProjects extends Workspace
14
{
15
    /**
16
     * @var string
17
     */
18
    public $uri = 'workspaces/{workspace_id}/projects?active={active}&actual_hours={actual_hours}&only_templates={only_templates}';
19
20
    /**
21
     * @var boolean
22
     */
23
    public $active = true;
24
25
    /**
26
     * @var boolean
27
     */
28
    public $actualHours = false;
29
30
    /**
31
     * @var boolean
32
     */
33
    public $onlyTemplates = false;
34
35
    /**
36
     * WorkspaceProjects constructor.
37
     *
38
     * @param array $properties
39
     */
40
    public function __construct(array $properties)
41
    {
42
        parent::__construct($properties);
43
44 View Code Duplication
        if ($this->active === true) {
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...
45
            $this->uri = str_replace('{active}', 'true', $this->uri);
46
        } else {
47
            $this->uri = str_replace('{active}', 'false', $this->uri);
48
        }
49
50
        if ($this->actualHours === true) {
51
            $this->uri = str_replace('{actual_hours}', 'true', $this->uri);
52
        } else {
53
            $this->uri = str_replace('{actual_hours}', 'false', $this->uri);
54
        }
55
56
        if ($this->onlyTemplates === true) {
57
            $this->uri = str_replace('{only_templates}', 'true', $this->uri);
58
        } else {
59
            $this->uri = str_replace('{only_templates}', 'false', $this->uri);
60
        }
61
    }
62
}
63