Completed
Push — master ( 4923e3...d627d1 )
by Joel
01:58
created
ConfirmationBehavior.php 1 patch
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -106,8 +106,9 @@  discard block
 block discarded – undo
106 106
 
107 107
         foreach ($changedValues as $attribute => $value) {
108 108
 
109
-            if ($this->skipOnNull && $value === null || $attribute == $this->timestampAttribute)
110
-                continue;
109
+            if ($this->skipOnNull && $value === null || $attribute == $this->timestampAttribute) {
110
+                            continue;
111
+            }
111 112
 
112 113
             if(!$this->isAuthorised($user, $attribute, $value)){
113 114
                 $this->createConfirmationRequest();
@@ -127,15 +128,17 @@  discard block
 block discarded – undo
127 128
     protected function isAuthorised($user, $attribute, $value){
128 129
 
129 130
         //Check for pre-defined administration roles
130
-        if ($this->userIsAuthorised($user))
131
-            return true;
131
+        if ($this->userIsAuthorised($user)) {
132
+                    return true;
133
+        }
132 134
 
133 135
         //Check for valid release token , eg that the token exists and is for the same record as this
134 136
         if($this->releaseToken != null){
135 137
             $confirmation =  ConfirmationRequest::findOne(['release_token' => $this->releaseToken]);
136 138
 
137
-            if($confirmation == null)
138
-                return false;
139
+            if($confirmation == null) {
140
+                            return false;
141
+            }
139 142
 
140 143
             $model = $confirmation->constructObject();
141 144
 
@@ -144,9 +147,10 @@  discard block
 block discarded – undo
144 147
         }
145 148
 
146 149
         //Check to see if any protected attributes have been altered
147
-        foreach ($this->protectedAttributes as $attribute)
148
-            if($this->hasChanged($attribute))
150
+        foreach ($this->protectedAttributes as $attribute) {
151
+                    if($this->hasChanged($attribute))
149 152
                 return false;
153
+        }
150 154
 
151 155
         return true;
152 156
     }
@@ -158,9 +162,10 @@  discard block
 block discarded – undo
158 162
      * @return bool
159 163
      */
160 164
     protected function userIsAuthorised($user){
161
-        foreach ($this->allow as $role)
162
-            if($user->can($role))
165
+        foreach ($this->allow as $role) {
166
+                    if($user->can($role))
163 167
                 return true;
168
+        }
164 169
 
165 170
         return false;
166 171
     }
@@ -204,9 +209,10 @@  discard block
 block discarded – undo
204 209
     public function getChangedValues(){
205 210
         $changedAttributes = [];
206 211
 
207
-        foreach ($this->owner->attributes() as $attribute)
208
-            if($this->hasChanged($attribute))
212
+        foreach ($this->owner->attributes() as $attribute) {
213
+                    if($this->hasChanged($attribute))
209 214
                 $changedAttributes[$attribute] = $this->owner->$attribute;
215
+        }
210 216
 
211 217
         unset($changedAttributes[$this->timestampAttribute]);
212 218
 
@@ -271,20 +277,25 @@  discard block
 block discarded – undo
271 277
         $email  = ArrayHelper::getValue($values,'email');
272 278
         $object = $model->constructObject();
273 279
 
274
-        if($email == null)
275
-            $email = ArrayHelper::getValue($values,'email_address');
280
+        if($email == null) {
281
+                    $email = ArrayHelper::getValue($values,'email_address');
282
+        }
276 283
 
277
-        if($email == null)
278
-            $email = ArrayHelper::getValue($object,'email');
284
+        if($email == null) {
285
+                    $email = ArrayHelper::getValue($object,'email');
286
+        }
279 287
 
280
-        if($email == null)
281
-            $email = ArrayHelper::getValue($object,'email_address');
288
+        if($email == null) {
289
+                    $email = ArrayHelper::getValue($object,'email_address');
290
+        }
282 291
 
283
-        if($email == null)
284
-            $email = ArrayHelper::getValue($object,$this->createdByAttribute.'.email');
292
+        if($email == null) {
293
+                    $email = ArrayHelper::getValue($object,$this->createdByAttribute.'.email');
294
+        }
285 295
 
286
-        if($email == null)
287
-            throw new InvalidCallException("Unable to locate email address via record, changed values, or user account");
296
+        if($email == null) {
297
+                    throw new InvalidCallException("Unable to locate email address via record, changed values, or user account");
298
+        }
288 299
 
289 300
         return $email;
290 301
     }
Please login to merge, or discard this patch.
ConfirmationRequest.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -126,9 +126,10 @@
 block discarded – undo
126 126
 
127 127
         foreach ($changedValues as $field => $value){
128 128
             $oldValue = $model->oldAttributes[$field];
129
-            if($current->$field !== $oldValue && $current->$field !== $value)
130
-                throw new ErrorException("Unable to release change, protected field $field has been updated since this request."
129
+            if($current->$field !== $oldValue && $current->$field !== $value) {
130
+                            throw new ErrorException("Unable to release change, protected field $field has been updated since this request."
131 131
                 . " Expected to find $value or $oldValue, found " . $current->$field);
132
+            }
132 133
 
133 134
         }
134 135
 
Please login to merge, or discard this patch.