Completed
Push — master ( fe6838...baec05 )
by Ievgen
02:20
created
src/Railway.php 4 patches
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
 use function einfach\operation\response\isValidResponse;
7 7
 use const einfach\operation\response\RESPONSE_TYPE_ERROR;
8 8
 use const einfach\operation\response\RESPONSE_TYPE_OK;
9
-use einfach\operation\step\Step;
10
-use einfach\operation\step\Failure;
11 9
 use einfach\operation\step\AbstractStep;
12 10
 use einfach\operation\step\Always;
11
+use einfach\operation\step\Failure;
12
+use einfach\operation\step\Step;
13 13
 use einfach\operation\step\TryCatch;
14 14
 
15 15
 class Railway
Please login to merge, or discard this patch.
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -33,6 +33,9 @@  discard block
 block discarded – undo
33 33
         $this->stepsQueue = [];
34 34
     }
35 35
 
36
+    /**
37
+     * @param string $stepName
38
+     */
36 39
     protected function findTargetStepIndex($stepName)
37 40
     {
38 41
         $steps = array_column($this->stepsQueue, 'step');
@@ -161,6 +164,7 @@  discard block
 block discarded – undo
161 164
 
162 165
     /**
163 166
      * @throws \Exception
167
+     * @param AbstractStep $step
164 168
      */
165 169
     protected function performStep($step, &$params, $opt, $track)
166 170
     {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -153,12 +153,12 @@
 block discarded – undo
153 153
             $opt = $item['opt'];
154 154
             /**
155 155
              * @var $step AbstractStep
156
-            */
156
+             */
157 157
             $track = $this->performStep($step, $params, $opt, $track);
158 158
 
159 159
             $failFast = $opt['failFast'] ?? null;
160 160
             if($failFast && $track == self::TRACK_FAILURE) {
161
-                 break;
161
+                    break;
162 162
             }
163 163
         }
164 164
         return new Result($params, $track, $this->signaturesPipeline);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     protected function findTargetStepIndex($stepName)
37 37
     {
38 38
         $steps = array_column($this->stepsQueue, 'step');
39
-        $names = array_map(function ($step) {
39
+        $names = array_map(function($step) {
40 40
             return $step->name();
41 41
         }, $steps);
42 42
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $track = $this->performStep($step, $params, $opt, $track);
159 159
 
160 160
             $failFast = $opt['failFast'] ?? null;
161
-            if($failFast && $track == self::TRACK_FAILURE) {
161
+            if ($failFast && $track == self::TRACK_FAILURE) {
162 162
                  break;
163 163
             }
164 164
         }
Please login to merge, or discard this patch.
src/step/AbstractStep.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
         $stepResult = $result;
70 70
         
71 71
         if (is_a($result, Result::class)) {
72
-             $stepResult = [
72
+                $stepResult = [
73 73
                     'params' => $result->params(),
74 74
                     'type' => ($result->isSuccess()) ? RESPONSE_TYPE_OK : RESPONSE_TYPE_ERROR
75 75
                 ];
Please login to merge, or discard this patch.
examples/crud/CRUDController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@
 block discarded – undo
37 37
 
38 38
     function actionAdminDelete($params)
39 39
     {
40
-        $params['user'] = (object) [ 'id' => 30, 'login' => 'admin'];
40
+        $params['user'] = (object) ['id' => 30, 'login' => 'admin'];
41 41
         $result = (new AdminDeleteOperation)($params);
42 42
         return $this->renderOperationResult($result);
43 43
     }
44 44
 
45 45
     protected function user() 
46 46
     {
47
-        return (object) [ 'id' => 20, 'login' => 'yevhen'];
47
+        return (object) ['id' => 20, 'login' => 'yevhen'];
48 48
     }
49 49
 
50 50
     protected function renderOperationResult($result)
Please login to merge, or discard this patch.
examples/crud/CRUDTraits.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     public function validate($params)
9 9
     {
10 10
         // pretend a lot of validations here
11
-        if($params['price'] > 100) {
11
+        if ($params['price'] > 100) {
12 12
             return ok($params);
13 13
         } else {
14 14
             return error($params, 'Too cheap to be true!');
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function checkPermissions($params)
19 19
     {
20
-        return ( $params['user']->login == 'yevhen' ) 
20
+        return ($params['user']->login == 'yevhen') 
21 21
                 ? ok($params) 
22 22
                 : error($params, 'Permission denied!');
23 23
     }
Please login to merge, or discard this patch.
examples/crud/AdminDeleteOperation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
     public function checkPermissions($params) 
20 20
     {
21
-        return ( $params['user']->login == 'admin' ) 
21
+        return ($params['user']->login == 'admin') 
22 22
                 ? ok($params) 
23 23
                 : error($params, 'Permission denied!');
24 24
     }
Please login to merge, or discard this patch.
examples/crud/example.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@
 block discarded – undo
8 8
 
9 9
 echo "Create \n\r";
10 10
 echo $controller->actionCreate(
11
-        [ 'name' => 'MacBook Pro 15', 'price' => '199' ]
11
+        ['name' => 'MacBook Pro 15', 'price' => '199']
12 12
     );
13 13
 
14 14
 echo "Read \n\r";
15 15
 echo $controller->actionRead(
16
-        [ 'id' => 10 ]
16
+        ['id' => 10]
17 17
     );
18 18
 
19 19
 echo "Update \n\r";
20 20
 echo $controller->actionUpdate(
21
-        [ 'id' => 10, 'name' => 'MacBook Air', 'price' => '119' ]
21
+        ['id' => 10, 'name' => 'MacBook Air', 'price' => '119']
22 22
     );
23 23
 
24 24
 echo "Delete \n\r";
25 25
 echo $controller->actionDelete(
26
-    [ 'id' => 10 ]
26
+    ['id' => 10]
27 27
 );
28 28
 
29 29
 echo "Admin Delete \n\r";
30 30
 echo $controller->actionAdminDelete(
31
-    [ 'id' => 10 ]
31
+    ['id' => 10]
32 32
 );
Please login to merge, or discard this patch.
examples/crud/CreateOperation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     public function create($params)
24 24
     {
25 25
         // pretend it is saved to DB and ID assigned
26
-        $model = [ 'id' => 10, 'price' => $params['price'], 'name' => $params['name']];
27
-        return ok($params, [ 'model' => $model ]);
26
+        $model = ['id' => 10, 'price' => $params['price'], 'name' => $params['name']];
27
+        return ok($params, ['model' => $model]);
28 28
     }
29 29
 }
Please login to merge, or discard this patch.
examples/crud/ReadOperation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     public function getArticle($params)
24 24
     {
25 25
         // pretend it is taken from DB
26
-        $article = (object) [ 'id' => 10, 'price' => 149, 'name' => 'MacBook Pro 13' ];
27
-        return ok($params, [ 'model' => $article ]);
26
+        $article = (object) ['id' => 10, 'price' => 149, 'name' => 'MacBook Pro 13'];
27
+        return ok($params, ['model' => $article]);
28 28
     }
29 29
 }
Please login to merge, or discard this patch.
examples/UpdateOperation.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     public function railway() : Railway
11 11
     {
12 12
         return (new Railway)
13
-            ->step(function ($params) {
13
+            ->step(function($params) {
14 14
                 echo "Hey {$params['name']}. Say hello to anonymous function!";
15 15
                 //return error($params, 'Early fail');
16 16
                 return ok($params, ['newParam' => 'newValue']);
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
             ->step([$this, 'nestedRailway'])
19 19
             ->step([$this, 'castRequest'], ['name' => 'CastReq'])
20 20
             ->step([$this, 'validateRequest'])
21
-            ->step(function ($params) {
21
+            ->step(function($params) {
22 22
                 return ok($params);
23 23
                 //return error($params, 'AAA!!!');
24 24
             }, ['failFast' => true])
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
             ->tryCatch([$this, 'sendNotification'])
29 29
             ->always([$this, 'writeLog'])
30 30
             ->failure([$this, 'notifyAdmin'], ['name' => 'Last'])
31
-            ->step(function ($params) {
31
+            ->step(function($params) {
32 32
                 return ok($params, ['a' => 'b']);
33 33
             }, ['after' => 'First', 'name' => 'FinalCheck']);
34 34
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function nestedRailway($params)
42 42
     {
43 43
         return (new Railway)
44
-            ->step(function ($params) {
44
+            ->step(function($params) {
45 45
                 //return error($params, 'Nested Railway failed!');
46 46
                 return ok($params, ['nestedRwParam' => 'nestedRwValue']);
47 47
             })
Please login to merge, or discard this patch.