@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | * @return \Wabel\CertainAPI\CertainRessourceAbstract |
52 | 52 | * @throws Exceptions\RessourceException |
53 | 53 | */ |
54 | - public function get($ressourceId= null,$params= array(), $assoc = false, $contentType='json'){ |
|
55 | - $ressourceName = $this->getRessourceName();; |
|
56 | - if($ressourceName == '' || is_null($ressourceName)){ |
|
54 | + public function get($ressourceId = null, $params = array(), $assoc = false, $contentType = 'json') { |
|
55 | + $ressourceName = $this->getRessourceName(); ; |
|
56 | + if ($ressourceName == '' || is_null($ressourceName)) { |
|
57 | 57 | throw new Exceptions\RessourceException('No ressource name provided.'); |
58 | 58 | } |
59 | - $this->results = $this->certainApiService->get($ressourceName,$this->ressourceCalled, $ressourceId,$params, $assoc, $contentType); |
|
59 | + $this->results = $this->certainApiService->get($ressourceName, $this->ressourceCalled, $ressourceId, $params, $assoc, $contentType); |
|
60 | 60 | return $this; |
61 | 61 | } |
62 | 62 | |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | * @throws Exceptions\RessourceException |
72 | 72 | * @throws Exceptions\RessourceMandatoryFieldException |
73 | 73 | */ |
74 | - public function post($bodyData, $query=array(), $ressourceId= null, $assoc = false, $contentType='json'){ |
|
75 | - $ressourceName = $this->getRessourceName();; |
|
76 | - if($ressourceName == '' || is_null($ressourceName)){ |
|
74 | + public function post($bodyData, $query = array(), $ressourceId = null, $assoc = false, $contentType = 'json') { |
|
75 | + $ressourceName = $this->getRessourceName(); ; |
|
76 | + if ($ressourceName == '' || is_null($ressourceName)) { |
|
77 | 77 | throw new Exceptions\RessourceException('No ressource name provided.'); |
78 | 78 | } |
79 | - if($ressourceId === null && count($this->getMandatoryFields())>0){ |
|
79 | + if ($ressourceId === null && count($this->getMandatoryFields())>0) { |
|
80 | 80 | foreach ($this->getMandatoryFields() as $field) { |
81 | - if(!in_array($field, array_keys($bodyData))){ |
|
82 | - throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required',$field)); |
|
81 | + if (!in_array($field, array_keys($bodyData))) { |
|
82 | + throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required', $field)); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | * @throws Exceptions\RessourceException |
99 | 99 | * @throws Exceptions\RessourceMandatoryFieldException |
100 | 100 | */ |
101 | - public function put($bodyData, $query=array(), $ressourceId= null, $assoc = false, $contentType='json'){ |
|
102 | - $ressourceName = $this->getRessourceName();; |
|
103 | - if($ressourceName == '' || is_null($ressourceName)){ |
|
101 | + public function put($bodyData, $query = array(), $ressourceId = null, $assoc = false, $contentType = 'json') { |
|
102 | + $ressourceName = $this->getRessourceName(); ; |
|
103 | + if ($ressourceName == '' || is_null($ressourceName)) { |
|
104 | 104 | throw new Exceptions\RessourceException('No ressource name provided.'); |
105 | 105 | } |
106 | - if(!is_null($ressourceId) && count($this->getMandatoryFields())>0){ |
|
106 | + if (!is_null($ressourceId) && count($this->getMandatoryFields())>0) { |
|
107 | 107 | foreach ($this->getMandatoryFields() as $field) { |
108 | - if(!in_array($field, array_keys($bodyData))){ |
|
109 | - throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required',$field)); |
|
108 | + if (!in_array($field, array_keys($bodyData))) { |
|
109 | + throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required', $field)); |
|
110 | 110 | } |
111 | 111 | } |
112 | - }else{ |
|
112 | + }else { |
|
113 | 113 | throw new Exceptions\RessourceMandatoryFieldException(sprintf('The id field is required')); |
114 | 114 | } |
115 | 115 | $this->results = $this->certainApiService->put($ressourceName, $this->ressourceCalled, $ressourceId, $bodyData, $query, $assoc, $contentType); |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | * @return \Wabel\CertainAPI\CertainRessourceAbstract |
125 | 125 | * @throws Exceptions\RessourceException |
126 | 126 | */ |
127 | - public function delete($ressourceId, $assoc = false, $contentType='json'){ |
|
128 | - $ressourceName = $this->getRessourceName();; |
|
129 | - if($ressourceName == '' || is_null($ressourceName)){ |
|
127 | + public function delete($ressourceId, $assoc = false, $contentType = 'json') { |
|
128 | + $ressourceName = $this->getRessourceName(); ; |
|
129 | + if ($ressourceName == '' || is_null($ressourceName)) { |
|
130 | 130 | throw new Exceptions\RessourceException('No ressource name provided.'); |
131 | 131 | } |
132 | 132 | $this->results = $this->certainApiService->delete($ressourceName, $this->ressourceCalled, $ressourceId, $assoc, $contentType); |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | * Check is not found. |
147 | 147 | * @return boolean |
148 | 148 | */ |
149 | - public function isNotFound(){ |
|
150 | - if(isset($this->results['statusCode']) && $this->results['statusCode'] == self::NOT_FOUND){ |
|
149 | + public function isNotFound() { |
|
150 | + if (isset($this->results['statusCode']) && $this->results['statusCode'] == self::NOT_FOUND) { |
|
151 | 151 | return true; |
152 | - } elseif (isset($this->results['statusCode']) && $this->results['statusCode'] != self::NOT_FOUND){ |
|
152 | + } elseif (isset($this->results['statusCode']) && $this->results['statusCode'] != self::NOT_FOUND) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | return null; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * Get the succes value, results, success or fail reason |
169 | 169 | * @return array |
170 | 170 | */ |
171 | - public function getCompleteResults(){ |
|
171 | + public function getCompleteResults() { |
|
172 | 172 | return $this->results; |
173 | 173 | } |
174 | 174 | |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | |
180 | 180 | public function createRessourceCalled($ressourceCalledParameters = null) |
181 | 181 | { |
182 | - if(is_array($ressourceCalledParameters) && !empty($ressourceCalledParameters)){ |
|
182 | + if (is_array($ressourceCalledParameters) && !empty($ressourceCalledParameters)) { |
|
183 | 183 | foreach ($ressourceCalledParameters as $segmentKey => $segmentValue) { |
184 | - if($segmentValue != ''){ |
|
184 | + if ($segmentValue != '') { |
|
185 | 185 | $this->ressourceCalled .= '/'.$segmentKey.'/'.$segmentValue; |
186 | - }else{ |
|
186 | + }else { |
|
187 | 187 | $this->ressourceCalled .= '/'.$segmentKey; |
188 | 188 | } |
189 | 189 |