Completed
Push — master ( 30403d...e08a79 )
by Raphaël
02:31
created
src/CertainRessourceAbstract.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
      * @return \Wabel\CertainAPI\CertainRessourceAbstract
51 51
      * @throws Exceptions\RessourceException
52 52
      */
53
-    public function get($ressourceId= null,$params= array(), $assoc = false, $contentType='json'){
54
-        $ressourceName = $this->getRessourceName();;
55
-        if($ressourceName == '' || is_null($ressourceName)){
53
+    public function get($ressourceId = null, $params = array(), $assoc = false, $contentType = 'json') {
54
+        $ressourceName = $this->getRessourceName(); ;
55
+        if ($ressourceName == '' || is_null($ressourceName)) {
56 56
             throw new Exceptions\RessourceException('No ressource name provided.');
57 57
         }
58
-        $this->results = $this->certainApiService->get($ressourceName,$this->ressourceCalled, $ressourceId,$params, $assoc, $contentType);
58
+        $this->results = $this->certainApiService->get($ressourceName, $this->ressourceCalled, $ressourceId, $params, $assoc, $contentType);
59 59
         return $this;
60 60
     }
61 61
 
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
      * @throws Exceptions\RessourceException
71 71
      * @throws Exceptions\RessourceMandatoryFieldException
72 72
      */
73
-    public function post($bodyData, $query=array(), $ressourceId= null, $assoc = false, $contentType='json'){
74
-        $ressourceName = $this->getRessourceName();;
75
-        if($ressourceName == '' || is_null($ressourceName)){
73
+    public function post($bodyData, $query = array(), $ressourceId = null, $assoc = false, $contentType = 'json') {
74
+        $ressourceName = $this->getRessourceName(); ;
75
+        if ($ressourceName == '' || is_null($ressourceName)) {
76 76
             throw new Exceptions\RessourceException('No ressource name provided.');
77 77
         }
78
-        if($ressourceId === null && count($this->getMandatoryFields())>0){
78
+        if ($ressourceId === null && count($this->getMandatoryFields())>0) {
79 79
             foreach ($this->getMandatoryFields() as $field) {
80
-                if(!in_array($field,  array_keys($bodyData))){
81
-                    throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required',$field));
80
+                if (!in_array($field, array_keys($bodyData))) {
81
+                    throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required', $field));
82 82
                 }
83 83
             }
84 84
         }
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
      * @throws Exceptions\RessourceException
98 98
      * @throws Exceptions\RessourceMandatoryFieldException
99 99
      */
100
-    public function put($bodyData, $query=array(), $ressourceId= null, $assoc = false, $contentType='json'){
101
-        $ressourceName = $this->getRessourceName();;
102
-        if($ressourceName == '' || is_null($ressourceName)){
100
+    public function put($bodyData, $query = array(), $ressourceId = null, $assoc = false, $contentType = 'json') {
101
+        $ressourceName = $this->getRessourceName(); ;
102
+        if ($ressourceName == '' || is_null($ressourceName)) {
103 103
             throw new Exceptions\RessourceException('No ressource name provided.');
104 104
         }
105
-        if(!is_null($ressourceId) && count($this->getMandatoryFields())>0){
105
+        if (!is_null($ressourceId) && count($this->getMandatoryFields())>0) {
106 106
             foreach ($this->getMandatoryFields() as $field) {
107
-                if(!in_array($field,  array_keys($bodyData))){
108
-                    throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required',$field));
107
+                if (!in_array($field, array_keys($bodyData))) {
108
+                    throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required', $field));
109 109
                 }
110 110
             }
111
-        }else{
111
+        }else {
112 112
             throw new Exceptions\RessourceMandatoryFieldException(sprintf('The id field is required'));
113 113
         }
114 114
         $this->results = $this->certainApiService->put($ressourceName, $this->ressourceCalled, $ressourceId, $bodyData, $query, $assoc, $contentType);
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
      * @return \Wabel\CertainAPI\CertainRessourceAbstract
124 124
      * @throws Exceptions\RessourceException
125 125
      */
126
-    public function delete($ressourceId, $assoc = false, $contentType='json'){
127
-        $ressourceName = $this->getRessourceName();;
128
-        if($ressourceName == '' || is_null($ressourceName)){
126
+    public function delete($ressourceId, $assoc = false, $contentType = 'json') {
127
+        $ressourceName = $this->getRessourceName(); ;
128
+        if ($ressourceName == '' || is_null($ressourceName)) {
129 129
             throw new Exceptions\RessourceException('No ressource name provided.');
130 130
         }
131 131
         $this->results = $this->certainApiService->delete($ressourceName, $this->ressourceCalled, $ressourceId, $assoc, $contentType);
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      * Get the succes value, results,  success or fail reason
155 155
      * @return array
156 156
      */
157
-    public function getCompleteResults(){
157
+    public function getCompleteResults() {
158 158
         return $this->results;
159 159
     }
160 160
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 
166 166
     public function createRessourceCalled($ressourceCalledParameters = null)
167 167
     {
168
-        if(is_array($ressourceCalledParameters) && !empty($ressourceCalledParameters)){
168
+        if (is_array($ressourceCalledParameters) && !empty($ressourceCalledParameters)) {
169 169
             foreach ($ressourceCalledParameters as $segmentKey => $segmentValue) {
170
-                if($segmentValue != ''){
170
+                if ($segmentValue != '') {
171 171
                     $this->ressourceCalled .= '/'.$segmentKey.'/'.$segmentValue;
172
-                }else{
172
+                }else {
173 173
                     $this->ressourceCalled .= '/'.$segmentKey;
174 174
                 }
175 175
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                     throw new Exceptions\RessourceMandatoryFieldException(sprintf('The field %s is required',$field));
109 109
                 }
110 110
             }
111
-        }else{
111
+        } else{
112 112
             throw new Exceptions\RessourceMandatoryFieldException(sprintf('The id field is required'));
113 113
         }
114 114
         $this->results = $this->certainApiService->put($ressourceName, $this->ressourceCalled, $ressourceId, $bodyData, $query, $assoc, $contentType);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             foreach ($ressourceCalledParameters as $segmentKey => $segmentValue) {
170 170
                 if($segmentValue != ''){
171 171
                     $this->ressourceCalled .= '/'.$segmentKey.'/'.$segmentValue;
172
-                }else{
172
+                } else{
173 173
                     $this->ressourceCalled .= '/'.$segmentKey;
174 174
                 }
175 175
 
Please login to merge, or discard this patch.