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

ViewMode   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 81
Duplicated Lines 11.11 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 9
loc 81
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setId() 9 9 2
A getId() 0 4 1
A getLabel() 0 4 1
A getUrl() 0 4 1
A getHtml() 0 4 1
A getPreviewImage() 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 ViewMode extends \ArrayObject
8
{
9
    use EntityTrait;
10
11
  /**
12
   * @param array $array
13
   */
14
  public function __construct(array $array = [])
15
  {
16
      parent::__construct($array);
17
  }
18
19
  /**
20
   * Sets the 'id' parameter.
21
   *
22
   * @param string $id
23
   *
24
   * @throws \Acquia\LiftClient\Exception\LiftSdkException
25
   *
26
   * @return \Acquia\LiftClient\Entity\ViewMode
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
   * Gets the 'id' parameter.
50
   *
51
   * @return string
52
   */
53
  public function getLabel()
54
  {
55
      return $this->getEntityValue('label', '');
56
  }
57
58
  /**
59
   * Gets the 'url' parameter.
60
   *
61
   * @return string
62
   */
63
  public function getUrl()
64
  {
65
      return $this->getEntityValue('url', '');
66
  }
67
68
  /**
69
   * Gets the 'html' parameter.
70
   *
71
   * @return string
72
   */
73
  public function getHtml()
74
  {
75
      return $this->getEntityValue('html', '');
76
  }
77
78
  /**
79
   * Gets the 'preview_image' parameter.
80
   *
81
   * @return string
82
   */
83
  public function getPreviewImage()
84
  {
85
      return $this->getEntityValue('preview_image', '');
86
  }
87
}
88