Completed
Pull Request — master (#6)
by Nick
02:39
created

Content::setContentConnectorId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
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
  public function setId($id)
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
  /**
104
   * @param ViewMode $viewMode
105
   *
106
   * @throws \Acquia\LiftClient\Exception\LiftSdkException
107
   *
108
   * @return \Acquia\LiftClient\Entity\Content
109
   */
110
  public function setViewMode(ViewMode $viewMode)
111
  {
112
    $this['view_mode'] = $viewMode->getArrayCopy();
113
    return $this;
114
  }
115
116
  /**
117
   * Gets the 'id' parameter.
118
   *
119
   * @return viewMode
120
   */
121
  public function getViewMode()
122
  {
123
    $viewMode = $this->getEntityValue('view_mode', []);
124
    return new ViewMode($viewMode);
125
  }
126
127
  /**
128
   * Gets the 'error' parameter.
129
   *
130
   * @return string
131
   */
132
  public function getError()
133
  {
134
      return $this->getEntityValue('error', '');
135
  }
136
}
137