@@ -87,7 +87,7 @@ |
||
87 | 87 | public function registerViaConnectionMethod() |
88 | 88 | { |
89 | 89 | foreach ($this->classes as $driver => $class) { |
90 | - Connection::resolverFor($driver, function ($connection, $database, $prefix, $config) use ($class) { |
|
90 | + Connection::resolverFor($driver, function($connection, $database, $prefix, $config) use ($class) { |
|
91 | 91 | return new $class($connection, $database, $prefix, $config); |
92 | 92 | }); |
93 | 93 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $builder = parent::getSchemaBuilder(); |
19 | 19 | |
20 | 20 | // add a blueprint resolver closure that returns the custom blueprint |
21 | - $builder->blueprintResolver(function ($table, $callback) { |
|
21 | + $builder->blueprintResolver(function($table, $callback) { |
|
22 | 22 | return new Blueprint($table, $callback); |
23 | 23 | }); |
24 | 24 |
@@ -70,11 +70,11 @@ |
||
70 | 70 | $stub = isset($stub) ? $stub : $this->stub; |
71 | 71 | $path = config('repository.generator.stubsOverridePath', __DIR__); |
72 | 72 | |
73 | - if (! file_exists($path.'/Stubs/'.$stub.'.stub')) { |
|
73 | + if (!file_exists($path.'/Stubs/'.$stub.'.stub')) { |
|
74 | 74 | $path = __DIR__; |
75 | 75 | } |
76 | 76 | |
77 | - return ( new Stub($path.'/Stubs/'.$stub.'.stub', $this->getReplacements()) )->render(); |
|
77 | + return (new Stub($path.'/Stubs/'.$stub.'.stub', $this->getReplacements()))->render(); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public function getReplacements() |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | * @author Milkmeowo <[email protected]> |
8 | 8 | */ |
9 | -if (! function_exists('is_lumen')) { |
|
9 | +if (!function_exists('is_lumen')) { |
|
10 | 10 | /** |
11 | 11 | * Checks whether or not the application is Lumen. |
12 | 12 | * |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | return $is_lumen; |
21 | 21 | } |
22 | 22 | } |
23 | -if (! function_exists('is_laravel')) { |
|
23 | +if (!function_exists('is_laravel')) { |
|
24 | 24 | /** |
25 | 25 | * Checks whether or not the application is Laravel. |
26 | 26 | * |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function is_laravel() |
30 | 30 | { |
31 | - return ! is_lumen(); |
|
31 | + return !is_lumen(); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | -if (! function_exists('app_path')) { |
|
35 | +if (!function_exists('app_path')) { |
|
36 | 36 | /** |
37 | 37 | * Get the path to the application folder. |
38 | 38 | * |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -if (! function_exists('bcrypt')) { |
|
49 | +if (!function_exists('bcrypt')) { |
|
50 | 50 | /** |
51 | 51 | * Hash the given value. |
52 | 52 | * |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | -if (! function_exists('smart_get_client_ip')) { |
|
64 | +if (!function_exists('smart_get_client_ip')) { |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @return array|string |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function validateCreate(array $attributes) |
36 | 36 | { |
37 | - if (! is_null($this->validator)) { |
|
37 | + if (!is_null($this->validator)) { |
|
38 | 38 | $this->validator->with($attributes)->passesOrFail(ValidatorInterface::RULE_CREATE); |
39 | 39 | } |
40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function validateUpdate(array $attributes) |
46 | 46 | { |
47 | - if (! is_null($this->validator)) { |
|
47 | + if (!is_null($this->validator)) { |
|
48 | 48 | $this->validator->with($attributes)->passesOrFail(ValidatorInterface::RULE_UPDATE); |
49 | 49 | } |
50 | 50 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function makeModel() |
94 | 94 | { |
95 | 95 | $model = $this->relateModel ? $this->relation() : $this->app->make($this->model()); |
96 | - if (! ($model instanceof Model || $model instanceof Relation)) { |
|
96 | + if (!($model instanceof Model || $model instanceof Relation)) { |
|
97 | 97 | throw new RepositoryException('Class '.get_class($model).' must be an instance of Illuminate\\Database\\Eloquent\\Model'); |
98 | 98 | } |
99 | 99 |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | { |
101 | 101 | $ip = smart_get_client_ip(); |
102 | 102 | |
103 | - if (! $this->isDirty(static::UPDATED_IP) && $this->hasTableColumn(static::UPDATED_IP)) { |
|
103 | + if (!$this->isDirty(static::UPDATED_IP) && $this->hasTableColumn(static::UPDATED_IP)) { |
|
104 | 104 | $this->{static::UPDATED_IP} = $ip; |
105 | 105 | } |
106 | 106 | |
107 | - if (! $this->exists && ! $this->isDirty(static::CREATED_IP) && $this->hasTableColumn(static::CREATED_IP)) { |
|
107 | + if (!$this->exists && !$this->isDirty(static::CREATED_IP) && $this->hasTableColumn(static::CREATED_IP)) { |
|
108 | 108 | $this->{static::CREATED_IP} = $ip; |
109 | 109 | } |
110 | 110 | } |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | protected function updateUsers() |
128 | 128 | { |
129 | 129 | $user_id = $this->getAuthUserId(); |
130 | - if (! ($user_id > 0)) { |
|
130 | + if (!($user_id > 0)) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | - if (! $this->isDirty(static::UPDATED_BY) && $this->hasTableColumn(static::UPDATED_BY)) { |
|
134 | + if (!$this->isDirty(static::UPDATED_BY) && $this->hasTableColumn(static::UPDATED_BY)) { |
|
135 | 135 | $this->{static::UPDATED_BY} = $user_id; |
136 | 136 | } |
137 | 137 | |
138 | - if (! $this->exists && ! $this->isDirty(static::CREATED_BY) && $this->hasTableColumn(static::CREATED_BY)) { |
|
138 | + if (!$this->exists && !$this->isDirty(static::CREATED_BY) && $this->hasTableColumn(static::CREATED_BY)) { |
|
139 | 139 | $this->{static::CREATED_BY} = $user_id; |
140 | 140 | } |
141 | 141 | } |
@@ -169,6 +169,11 @@ discard block |
||
169 | 169 | $this->generateFile($path, $stub, $namespace); |
170 | 170 | } |
171 | 171 | |
172 | + /** |
|
173 | + * @param string $path |
|
174 | + * @param string $stub |
|
175 | + * @param null|string $namespace |
|
176 | + */ |
|
172 | 177 | public function generateFile($path, $stub, $namespace) |
173 | 178 | { |
174 | 179 | if ( ! $this->filesystem->exists($path) || $this->confirm($path.' already exists! Continue?')) { |
@@ -198,6 +203,9 @@ discard block |
||
198 | 203 | return $path.'/Stubs/base/'.$stub.'.stub'; |
199 | 204 | } |
200 | 205 | |
206 | + /** |
|
207 | + * @param string $stub |
|
208 | + */ |
|
201 | 209 | public function getStub($stub) |
202 | 210 | { |
203 | 211 | return $this->filesystem->get($this->getPath($stub)); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $stub = is_lumen() ? $this->stubs['api.controller.lumen'] : $this->stubs['api.controller.laravel']; |
94 | 94 | $stub = $this->getStub($stub); |
95 | 95 | |
96 | - $controllerGenerator = new ControllerGenerator([ 'name' => 'Base' ]); |
|
96 | + $controllerGenerator = new ControllerGenerator(['name' => 'Base']); |
|
97 | 97 | $namespace = $controllerGenerator->getNamespace(); |
98 | 98 | |
99 | 99 | $path = $controllerGenerator->getBasePath().'/'.$controllerGenerator->getConfigGeneratorClassPath($controllerGenerator->getPathConfigNode(), |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $stub = $this->stubs['model']; |
118 | 118 | $stub = $this->getStub($stub); |
119 | - $generator = new ModelGenerator([ 'name' => 'BaseModel' ]); |
|
119 | + $generator = new ModelGenerator(['name' => 'BaseModel']); |
|
120 | 120 | $namespace = $generator->getNamespace(); |
121 | 121 | $path = $generator->getPath(); |
122 | 122 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $stub = $this->stubs['presenter']; |
129 | 129 | $stub = $this->getStub($stub); |
130 | - $generator = new PresenterGenerator([ 'name' => 'Base' ]); |
|
130 | + $generator = new PresenterGenerator(['name' => 'Base']); |
|
131 | 131 | $namespace = $generator->getNamespace(); |
132 | 132 | $path = $generator->getPath(); |
133 | 133 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | { |
139 | 139 | $stub = $this->stubs['repositories.eloquent']; |
140 | 140 | $stub = $this->getStub($stub); |
141 | - $generator = new RepositoryEloquentGenerator([ 'name' => 'Base' ]); |
|
141 | + $generator = new RepositoryEloquentGenerator(['name' => 'Base']); |
|
142 | 142 | $namespace = $generator->getNamespace(); |
143 | 143 | $path = $generator->getBasePath().'/'.$generator->getConfigGeneratorClassPath($generator->getPathConfigNode(), |
144 | 144 | true).'/BaseRepository.php'; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $stub = $this->stubs['repositories.interfaces']; |
152 | 152 | $stub = $this->getStub($stub); |
153 | - $generator = new RepositoryInterfaceGenerator([ 'name' => 'Base' ]); |
|
153 | + $generator = new RepositoryInterfaceGenerator(['name' => 'Base']); |
|
154 | 154 | $namespace = $generator->getNamespace(); |
155 | 155 | $path = $generator->getBasePath().'/'.$generator->getConfigGeneratorClassPath($generator->getPathConfigNode(), |
156 | 156 | true).'/BaseRepositoryInterface.php'; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | { |
163 | 163 | $stub = $this->stubs['transformer']; |
164 | 164 | $stub = $this->getStub($stub); |
165 | - $generator = new TransformerGenerator([ 'name' => 'Base' ]); |
|
165 | + $generator = new TransformerGenerator(['name' => 'Base']); |
|
166 | 166 | $namespace = $generator->getNamespace(); |
167 | 167 | $path = $generator->getPath(); |
168 | 168 | |
@@ -171,16 +171,16 @@ discard block |
||
171 | 171 | |
172 | 172 | public function generateFile($path, $stub, $namespace) |
173 | 173 | { |
174 | - if ( ! $this->filesystem->exists($path) || $this->confirm($path.' already exists! Continue?')) { |
|
174 | + if (!$this->filesystem->exists($path) || $this->confirm($path.' already exists! Continue?')) { |
|
175 | 175 | $content = str_replace('$NAMESPACE$', $namespace, $stub); |
176 | 176 | |
177 | - if (! $this->filesystem->isDirectory($dir = dirname($path))) { |
|
177 | + if (!$this->filesystem->isDirectory($dir = dirname($path))) { |
|
178 | 178 | $this->filesystem->makeDirectory($dir, 0777, true, true); |
179 | 179 | } |
180 | 180 | |
181 | 181 | $this->filesystem->put($path, $content); |
182 | 182 | $this->line('---------------'); |
183 | - $this->info($path ." generated"); |
|
183 | + $this->info($path." generated"); |
|
184 | 184 | $this->line('---------------'); |
185 | 185 | } |
186 | 186 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $path = config('repository.generator.stubsOverridePath', $defaultPath); |
192 | 192 | |
193 | 193 | // rollback |
194 | - if ( ! file_exists($path.'/Stubs/base/'.$stub.'.stub')) { |
|
194 | + if (!file_exists($path.'/Stubs/base/'.$stub.'.stub')) { |
|
195 | 195 | $path = $defaultPath; |
196 | 196 | } |
197 | 197 |