Passed
Branch master (857add)
by Daniel
02:45
created
config/mock.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@
 block discarded – undo
5 5
     "path" => "storage/mock", // Default folder path of the mock api
6 6
     "paginate" => true, // Define if we must paginate the results or not
7 7
     "per_page" => 10, // Define the number of items per page (if paginate = true)
8
-    "condition" => function(){ // The condition to define if the mock routing is enabled or not
8
+    "condition" => function() { // The condition to define if the mock routing is enabled or not
9 9
         return app()->isLocal();
10 10
     },
11 11
     "force_json" => true, // Force the whole mock controller to render application/json
12
-    "entrypoints" => [ // instead of looking into a folder you can also run a factory($class$, $number$)->states($state$)->make($override$) or add validation on controller method
12
+    "entrypoints" => [// instead of looking into a folder you can also run a factory($class$, $number$)->states($state$)->make($override$) or add validation on controller method
13 13
         /*"users" => [
14 14
             "class" => \App\User::class, // if null factory won't be triggerred
15 15
             "number" => 100, // number of factory to run
Please login to merge, or discard this patch.
src/MockServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
             'mock'
23 23
         );
24 24
 
25
-        $this->app->bind('mock', function () {
25
+        $this->app->bind('mock', function() {
26 26
             return new Mock();
27 27
         });
28 28
 
Please login to merge, or discard this patch.
src/Mock.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 
3 3
 namespace Blok\Mock;
4 4
 
5
-class Mock{
5
+class Mock {
6 6
 
7
-    public static function getPath(){
7
+    public static function getPath() {
8 8
         return config("mock.path");
9 9
     }
10 10
 
Please login to merge, or discard this patch.
src/Http/Controllers/MockController.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@
 block discarded – undo
150 150
         $data = $request->all();
151 151
         $data['id'] = uniqid();
152 152
 
153
-       \File::put($folder . '/' . $data['id'] . '.json', json_encode($data));
153
+        \File::put($folder . '/' . $data['id'] . '.json', json_encode($data));
154 154
 
155 155
         return $data;
156 156
     }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
      * @param $request Request
28 28
      * @throws \Illuminate\Validation\ValidationException
29 29
      */
30
-    public function _handleValidation($table, $method, $request){
30
+    public function _handleValidation($table, $method, $request) {
31 31
 
32
-        $validation = config("mock.entrypoints.".$table.".".$method."_validation");
32
+        $validation = config("mock.entrypoints." . $table . "." . $method . "_validation");
33 33
 
34
-        if (config("mock.force_json") || config("mock.entrypoints.".$table.".".$method."_force_json")) {
34
+        if (config("mock.force_json") || config("mock.entrypoints." . $table . "." . $method . "_force_json")) {
35 35
             $request->server->set('HTTP_ACCEPT', 'application/json');
36 36
             $request->headers = new HeaderBag($request->server->getHeaders());
37 37
         }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $this->_handleValidation($table, "index", $request);
62 62
 
63
-        $entity = config("mock.entrypoints.".$table);
63
+        $entity = config("mock.entrypoints." . $table);
64 64
 
65 65
         if ($entity) {
66 66
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
              */
70 70
             $data = factory($entity["class"], $entity["number"])->states($entity["states"])->make($entity["override"]);
71 71
 
72
-            $data = $data->map(function ($item, $key) {
72
+            $data = $data->map(function($item, $key) {
73 73
 
74 74
                 if (!$item["id"]) {
75 75
                     $item['id'] = $key + 1;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             $currentPageItems = $itemCollection->slice(($currentPage * $perPage) - $perPage, $perPage)->values()->all();
121 121
 
122 122
             // Create our paginator and pass it to the view
123
-            $paginatedItems= new LengthAwarePaginator($currentPageItems , count($itemCollection), $perPage);
123
+            $paginatedItems = new LengthAwarePaginator($currentPageItems, count($itemCollection), $perPage);
124 124
 
125 125
             // set url path for generted links
126 126
             $paginatedItems->setPath($request->url());
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $this->_handleValidation($table, "update", $request);
168 168
 
169
-        $folder = public_path(Mock::getPath() ."/". $table);
169
+        $folder = public_path(Mock::getPath() . "/" . $table);
170 170
 
171 171
         if (!is_dir($folder)) {
172 172
             \File::makeDirectory($folder, 493, true);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     {
195 195
         $this->_handleValidation($table, "view", $request);
196 196
 
197
-        $entity = config("mock.entrypoints.".$table);
197
+        $entity = config("mock.entrypoints." . $table);
198 198
 
199 199
         if ($entity) {
200 200
 
Please login to merge, or discard this patch.
routes/web.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@
 block discarded – undo
2 2
 
3 3
 use Blok\Mock\Mock;
4 4
 
5
-if(Mock::meetEnvCondition()){
6
-    Route::group(["namespace" => "Blok\\Mock\\Http\\Controllers"], function(){
7
-        Route::post(config("mock.route").'/{table}', 'MockController@store');
8
-        Route::any(config("mock.route").'/{table}/create', 'MockController@store');
9
-        Route::get(config("mock.route").'/{table}', 'MockController@index');
10
-        Route::any(config("mock.route").'/{table}/{id}/update', 'MockController@update');
11
-        Route::put(config("mock.route").'/{table}/{id}', 'MockController@update');
12
-        Route::get(config("mock.route").'/{table}/{id}', 'MockController@view');
5
+if (Mock::meetEnvCondition()) {
6
+    Route::group(["namespace" => "Blok\\Mock\\Http\\Controllers"], function() {
7
+        Route::post(config("mock.route") . '/{table}', 'MockController@store');
8
+        Route::any(config("mock.route") . '/{table}/create', 'MockController@store');
9
+        Route::get(config("mock.route") . '/{table}', 'MockController@index');
10
+        Route::any(config("mock.route") . '/{table}/{id}/update', 'MockController@update');
11
+        Route::put(config("mock.route") . '/{table}/{id}', 'MockController@update');
12
+        Route::get(config("mock.route") . '/{table}/{id}', 'MockController@view');
13 13
     });
14 14
 }
15 15
\ No newline at end of file
Please login to merge, or discard this patch.