Completed
Push — master ( 621ea2...dd23a3 )
by Nick
12s
created

Content   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 129
Duplicated Lines 13.95 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 3
dl 18
loc 129
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setId() 9 9 2
A getId() 0 4 1
A setContentConnectorId() 9 9 2
A getContentConnectorId() 0 4 1
A setBaseUrl() 0 9 2
A getBaseUrl() 0 4 1
A setViewMode() 0 6 1
A getViewMode() 0 6 1
A getError() 0 4 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
namespace Acquia\LiftClient\Entity;
4
5
use Acquia\LiftClient\Exception\LiftSdkException;
6
7
class Content extends Entity
8
{
9
    /**
10
     * @param array $array
11
     */
12
    public function __construct(array $array = [])
13
    {
14
        // Set content_hub as default content_connector_id when adding content
15
        $array['content_connector_id'] = 'content_hub';
16
        parent::__construct($array);
17
    }
18
19
    /**
20
     * @param string $id
21
     *
22
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
23
     *
24
     * @return \Acquia\LiftClient\Entity\Content
25
     */
26 View Code Duplication
    public function setId($id)
27
    {
28
        if (!is_string($id)) {
29
            throw new LiftSdkException('Argument must be an instance of string.');
30
        }
31
        $this['id'] = $id;
32
33
        return $this;
34
    }
35
36
    /**
37
     * Gets the 'id' parameter.
38
     *
39
     * @return string
40
     */
41
    public function getId()
42
    {
43
        return $this->getEntityValue('id', '');
44
    }
45
46
    /**
47
     * @param string $contentConnectorId
48
     *
49
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
50
     *
51
     * @return \Acquia\LiftClient\Entity\Content
52
     */
53 View Code Duplication
    public function setContentConnectorId($contentConnectorId = 'content_hub')
54
    {
55
        if (!is_string($contentConnectorId)) {
56
            throw new LiftSdkException('Argument must be an instance of string.');
57
        }
58
        $this['content_connector_id'] = $contentConnectorId;
59
60
        return $this;
61
    }
62
63
    /**
64
     * Gets the 'content_connector_id' parameter.
65
     *
66
     * @return string
67
     */
68
    public function getContentConnectorId()
69
    {
70
        return $this->getEntityValue('content_connector_id', 'content_hub');
71
    }
72
73
    /**
74
     * @param string $baseUrl
75
     *
76
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
77
     *
78
     * @return \Acquia\LiftClient\Entity\Content
79
     */
80
    public function setBaseUrl($baseUrl)
81
    {
82
        if (!is_string($baseUrl)) {
83
            throw new LiftSdkException('Argument must be an instance of string.');
84
        }
85
        $this['base_url'] = $baseUrl;
86
87
        return $this;
88
    }
89
90
    /**
91
     * Gets the 'base_url' parameter.
92
     *
93
     * @return string
94
     */
95
    public function getBaseUrl()
96
    {
97
        return $this->getEntityValue('base_url', '');
98
    }
99
100
    /**
101
     * @param ViewMode $viewMode
102
     *
103
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
104
     *
105
     * @return \Acquia\LiftClient\Entity\Content
106
     */
107
    public function setViewMode(ViewMode $viewMode)
108
    {
109
        $this['view_mode'] = $viewMode->getArrayCopy();
110
111
        return $this;
112
    }
113
114
    /**
115
     * Gets the 'id' parameter.
116
     *
117
     * @return viewMode
118
     */
119
    public function getViewMode()
120
    {
121
        $viewMode = $this->getEntityValue('view_mode', []);
122
123
        return new ViewMode($viewMode);
124
    }
125
126
    /**
127
     * Gets the 'error' parameter.
128
     *
129
     * @return string
130
     */
131
    public function getError()
132
    {
133
        return $this->getEntityValue('error', '');
134
    }
135
}
136