Completed
Pull Request — master (#6)
by Nick
15:48
created

Content   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 105
Duplicated Lines 17.14 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 18
loc 105
rs 10
c 0
b 0
f 0

8 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 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 \ArrayObject
8
{
9
    use EntityTrait;
10
11
  /**
12
   * @param array $array
13
   */
14
  public function __construct(array $array = [])
15
  {
16
      // Set content_hub as default content_connector_id when adding content
17
    $array['content_connector_id'] = 'content_hub';
18
      parent::__construct($array);
19
  }
20
21
  /**
22
   * @param string $id
23
   *
24
   * @throws \Acquia\LiftClient\Exception\LiftSdkException
25
   *
26
   * @return \Acquia\LiftClient\Entity\Content
27
   */
28 View Code Duplication
  public function setId($id)
1 ignored issue
show
Duplication introduced by
This method 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...
29
  {
30
      if (!is_string($id)) {
31
          throw new LiftSdkException('Argument must be an instance of string.');
32
      }
33
      $this['id'] = $id;
34
35
      return $this;
36
  }
37
38
  /**
39
   * Gets the 'id' parameter.
40
   *
41
   * @return string
42
   */
43
  public function getId()
44
  {
45
      return $this->getEntityValue('id', '');
46
  }
47
48
  /**
49
   * @param string $contentConnectorId
50
   *
51
   * @throws \Acquia\LiftClient\Exception\LiftSdkException
52
   *
53
   * @return \Acquia\LiftClient\Entity\Content
54
   */
55 View Code Duplication
  public function setContentConnectorId($contentConnectorId = 'content_hub')
1 ignored issue
show
Duplication introduced by
This method 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...
56
  {
57
      if (!is_string($contentConnectorId)) {
58
          throw new LiftSdkException('Argument must be an instance of string.');
59
      }
60
      $this['content_connector_id'] = $contentConnectorId;
61
62
      return $this;
63
  }
64
65
  /**
66
   * Gets the 'content_connector_id' parameter.
67
   *
68
   * @return string
69
   */
70
  public function getContentConnectorId()
71
  {
72
      return $this->getEntityValue('content_connector_id', 'content_hub');
73
  }
74
75
  /**
76
   * @param string $baseUrl
77
   *
78
   * @throws \Acquia\LiftClient\Exception\LiftSdkException
79
   *
80
   * @return \Acquia\LiftClient\Entity\Content
81
   */
82
  public function setBaseUrl($baseUrl)
83
  {
84
      if (!is_string($baseUrl)) {
85
          throw new LiftSdkException('Argument must be an instance of string.');
86
      }
87
      $this['base_url'] = $baseUrl;
88
89
      return $this;
90
  }
91
92
  /**
93
   * Gets the 'base_url' parameter.
94
   *
95
   * @return string
96
   */
97
  public function getBaseUrl()
98
  {
99
      return $this->getEntityValue('base_url', '');
100
  }
101
102
  /**
103
   * Gets the 'error' parameter.
104
   *
105
   * @return string
106
   */
107
  public function getError()
108
  {
109
      return $this->getEntityValue('error', '');
110
  }
111
}
112