Conditions | 9 |
Paths | 16 |
Total Lines | 66 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php namespace Anomaly\Streams\Platform\Application\Command; |
||
22 | public function handle(Application $application, Laravel $laravel) |
||
23 | { |
||
24 | $app = env('APPLICATION_REFERENCE', 'default'); |
||
25 | |||
26 | if (PHP_SAPI == 'cli') { |
||
27 | $app = (new ArgvInput())->getParameterOption('--app', $app); |
||
28 | |||
29 | $laravel->bind( |
||
30 | 'path.public', |
||
31 | function () use ($laravel) { |
||
32 | if ($path = env('PUBLIC_PATH')) { |
||
33 | return base_path($path); |
||
34 | } |
||
35 | |||
36 | // Check default path. |
||
37 | if (file_exists($path = base_path('public/index.php'))) { |
||
38 | return dirname($path); |
||
39 | } |
||
40 | |||
41 | // Check common alternative. |
||
42 | if (file_exists($path = base_path('public_html/index.php'))) { |
||
43 | return dirname($path); |
||
44 | } |
||
45 | |||
46 | return base_path('public'); |
||
47 | } |
||
48 | ); |
||
49 | } |
||
50 | |||
51 | /* |
||
52 | * Set the reference to our default first. |
||
53 | * When in a dev environment and working |
||
54 | * with Artisan this the same as locating. |
||
55 | */ |
||
56 | $application->setReference($app); |
||
57 | |||
58 | /* |
||
59 | * If the application is installed |
||
60 | * then locate the application and |
||
61 | * initialize. |
||
62 | */ |
||
63 | if ($application->isInstalled()) { |
||
64 | |||
65 | if (env('DB_CONNECTION', env('DB_DRIVER'))) { |
||
66 | |||
67 | try { |
||
68 | $application->locate(); |
||
69 | $application->setup(); |
||
70 | |||
71 | if (!$application->isEnabled()) { |
||
72 | abort(503); |
||
73 | } |
||
74 | } catch(\Exception $e) { |
||
75 | // Do nothing. |
||
76 | } |
||
77 | } |
||
78 | |||
79 | return; |
||
80 | } |
||
81 | |||
82 | /* |
||
83 | * If we're not installed just |
||
84 | * assume default for now. |
||
85 | */ |
||
86 | $application->setReference('default'); |
||
87 | } |
||
88 | } |
||
89 |