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

WorkspaceProjects::__construct()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 22
Code Lines 14

Duplication

Lines 5
Ratio 22.73 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 5
loc 22
rs 8.9197
cc 4
eloc 14
nc 8
nop 1
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