GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

artisan()   B
last analyzed

Complexity

Conditions 10
Paths 1

Size

Total Lines 34
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 110

Importance

Changes 0
Metric Value
cc 10
eloc 16
nc 1
nop 2
dl 0
loc 34
ccs 0
cts 24
cp 0
crap 110
rs 7.6666
c 0
b 0
f 0

How to fix   Complexity   

Long Method

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:

1
<?php
2
3
namespace Deployer;
4
5
require_once __DIR__ . '/common.php';
6
7
add('recipes', ['laravel']);
8
9
set('shared_dirs', ['storage']);
10
set('shared_files', ['.env']);
11
set('writable_dirs', [
12
    'bootstrap/cache',
13
    'storage',
14
    'storage/app',
15
    'storage/app/public',
16
    'storage/framework',
17
    'storage/framework/cache',
18
    'storage/framework/cache/data',
19
    'storage/framework/sessions',
20
    'storage/framework/views',
21
    'storage/logs',
22
]);
23
set('log_files', 'storage/logs/*.log');
24
set('bin/artisan', '{{release_or_current_path}}/artisan');
25
set('laravel_version', function () {
26
    $result = run("{{bin/php}} {{bin/artisan}} --version");
27
    preg_match_all('/(\d+\.?)+/', $result, $matches);
28
    return $matches[0][0] ?? 5.5;
29
});
30
set('public_path', 'public');
31
32
/**
33
 * Run an artisan command.
34
 *
35
 * Supported options:
36
 * - 'min' => #.#: The minimum Laravel version required (included).
37
 * - 'max' => #.#: The maximum Laravel version required (included).
38
 * - 'skipIfNoEnv': Skip and warn the user if `.env` file is inexistant or empty.
39
 * - 'failIfNoEnv': Fail the command if `.env` file is inexistant or empty.
40
 * - 'showOutput': Show the output of the command if given.
41
 *
42
 * @param string $command The artisan command (with cli options if any).
43
 * @param array $options The options that define the behaviour of the command.
44
 * @return callable A function that can be used as a task.
45
 */
46
function artisan($command, $options = [])
47
{
48
    return function () use ($command, $options) {
49
50
        // Ensure the artisan command is available on the current version.
51
        $versionTooEarly = array_key_exists('min', $options)
52
            && laravel_version_compare($options['min'], '<');
53
54
        $versionTooLate = array_key_exists('max', $options)
55
            && laravel_version_compare($options['max'], '>');
56
57
        if ($versionTooEarly || $versionTooLate) {
58
            return;
59
        }
60
61
        // Get the dotenv path or use default.
62
        $dotenv = get('dotenv', '{{release_or_current_path}}/.env');
63
64
        // Ensure we warn or fail when a command relies on the ".env" file.
65
        if (in_array('failIfNoEnv', $options) && !test("[ -s $dotenv ]")) {
66
            throw new \Exception('Your .env file is empty! Cannot proceed.');
67
        }
68
69
        if (in_array('skipIfNoEnv', $options) && !test("[ -s $dotenv ]")) {
70
            warning("Your .env file is empty! Skipping...</>");
71
            return;
72
        }
73
74
        // Run the artisan command.
75
        $output = run("{{bin/php}} {{bin/artisan}} $command");
76
77
        // Output the results when appropriate.
78
        if (in_array('showOutput', $options)) {
79
            writeln("<info>$output</info>");
80
        }
81
    };
82
}
83
84
function laravel_version_compare($version, $comparator)
85
{
86
    return version_compare(get('laravel_version'), $version, $comparator);
87
}
88
89
/*
90
 * Maintenance mode.
91
 */
92
93
desc('Puts the application into maintenance / demo mode');
94
task('artisan:down', artisan('down', ['showOutput']));
95
96
desc('Brings the application out of maintenance mode');
97
task('artisan:up', artisan('up', ['showOutput']));
98
99
/*
100
 * Generate keys.
101
 */
102
103
desc('Sets the application key');
104
task('artisan:key:generate', artisan('key:generate'));
105
106
desc('Creates the encryption keys for API authentication');
107
task('artisan:passport:keys', artisan('passport:keys'));
108
109
/*
110
 * Database and migrations.
111
 */
112
113
desc('Seeds the database with records');
114
task('artisan:db:seed', artisan('db:seed --force', ['skipIfNoEnv', 'showOutput']));
115
116
desc('Runs the database migrations');
117
task('artisan:migrate', artisan('migrate --force', ['skipIfNoEnv']));
118
119
desc('Drops all tables and re-run all migrations');
120
task('artisan:migrate:fresh', artisan('migrate:fresh --force', ['skipIfNoEnv']));
121
122
desc('Rollbacks the last database migration');
123
task('artisan:migrate:rollback', artisan('migrate:rollback --force', ['skipIfNoEnv', 'showOutput']));
124
125
desc('Shows the status of each migration');
126
task('artisan:migrate:status', artisan('migrate:status', ['skipIfNoEnv', 'showOutput']));
127
128
/*
129
 * Cache and optimizations.
130
 */
131
132
desc('Flushes the application cache');
133
task('artisan:cache:clear', artisan('cache:clear'));
134
135
desc('Creates a cache file for faster configuration loading');
136
task('artisan:config:cache', artisan('config:cache'));
137
138
desc('Removes the configuration cache file');
139
task('artisan:config:clear', artisan('config:clear'));
140
141
desc('Discovers and cache the application\'s events and listeners');
142
task('artisan:event:cache', artisan('event:cache', ['min' => '5.8.9']));
143
144
desc('Clears all cached events and listeners');
145
task('artisan:event:clear', artisan('event:clear', ['min' => '5.8.9']));
146
147
desc('Lists the application\'s events and listeners');
148
task('artisan:event:list', artisan('event:list', ['showOutput', 'min' => '5.8.9']));
149
150
desc('Cache the framework bootstrap files');
151
task('artisan:optimize', artisan('optimize'));
152
153
desc('Removes the cached bootstrap files');
154
task('artisan:optimize:clear', artisan('optimize:clear'));
155
156
desc('Creates a route cache file for faster route registration');
157
task('artisan:route:cache', artisan('route:cache'));
158
159
desc('Removes the route cache file');
160
task('artisan:route:clear', artisan('route:clear'));
161
162
desc('Lists all registered routes');
163
task('artisan:route:list', artisan('route:list', ['showOutput']));
164
165
desc('Creates the symbolic links configured for the application');
166
task('artisan:storage:link', artisan('storage:link', ['min' => 5.3]));
167
168
desc('Compiles all of the application\'s Blade templates');
169
task('artisan:view:cache', artisan('view:cache', ['min' => 5.6]));
170
171
desc('Clears all compiled view files');
172
task('artisan:view:clear', artisan('view:clear'));
173
174
/**
175
 * Queue and Horizon.
176
 */
177
178
desc('Lists all of the failed queue jobs');
179
task('artisan:queue:failed', artisan('queue:failed', ['showOutput']));
180
181
desc('Flushes all of the failed queue jobs');
182
task('artisan:queue:flush', artisan('queue:flush'));
183
184
desc('Restarts queue worker daemons after their current job');
185
task('artisan:queue:restart', artisan('queue:restart'));
186
187
desc('Starts a master supervisor in the foreground');
188
task('artisan:horizon', artisan('horizon'));
189
190
desc('Deletes all of the jobs from the specified queue');
191
task('artisan:horizon:clear', artisan('horizon:clear --force'));
192
193
desc('Instructs the master supervisor to continue processing jobs');
194
task('artisan:horizon:continue', artisan('horizon:continue'));
195
196
desc('Lists all of the deployed machines');
197
task('artisan:horizon:list', artisan('horizon:list', ['showOutput']));
198
199
desc('Pauses the master supervisor');
200
task('artisan:horizon:pause', artisan('horizon:pause'));
201
202
desc('Terminates any rogue Horizon processes');
203
task('artisan:horizon:purge', artisan('horizon:purge'));
204
205
desc('Gets the current status of Horizon');
206
task('artisan:horizon:status', artisan('horizon:status', ['showOutput']));
207
208
desc('Terminates the master supervisor so it can be restarted');
209
task('artisan:horizon:terminate', artisan('horizon:terminate'));
210
211
desc('Publish all of the Horizon resources');
212
task('artisan:horizon:publish', artisan('horizon:publish'));
213
214
desc('Lists all of the supervisors');
215
task('artisan:horizon:supervisors', artisan('horizon:supervisors', ['showOutput']));
216
217
desc('Deletes metrics for all jobs and queues');
218
task('artisan:horizon:clear-metrics', artisan('horizon:clear-metrics'));
219
220
desc('Stores a snapshot of the queue metrics');
221
task('artisan:horizon:snapshot', artisan('horizon:snapshot'));
222
223
/*
224
 * Scheduler.
225
 */
226
227
desc('Interrupt in-progress schedule:run invocations');
228
task('artisan:schedule:interrupt', artisan('schedule:interrupt'));
229
230
/*
231
 * Telescope.
232
 */
233
234
desc('Clears all entries from Telescope');
235
task('artisan:telescope:clear', artisan('telescope:clear'));
236
237
desc('Prunes stale entries from the Telescope database');
238
task('artisan:telescope:prune', artisan('telescope:prune'));
239
240
/*
241
 * Octane.
242
 */
243
244
desc('Starts the octane server');
245
task('artisan:octane', artisan('octane:start'));
246
247
desc('Reloads the octane server');
248
task('artisan:octane:reload', artisan('octane:reload'));
249
250
desc('Stops the octane server');
251
task('artisan:octane:stop', artisan('octane:stop'));
252
253
desc('Check the status of the octane server');
254
task('artisan:octane:status', artisan('octane:status'));
255
256
/*
257
 * Nova.
258
 */
259
260
desc('Publish all of the Laravel Nova resources');
261
task('artisan:nova:publish', artisan('nova:publish'));
262
263
/*
264
 * Reverb.
265
 */
266
267
desc('Starts the Reverb server');
268
task('artisan:reverb:start', artisan('reverb:start'));
269
270
desc('Restarts the Reverb server');
271
task('artisan:reverb:restart', artisan('reverb:restart'));
272
273
/*
274
 * Pulse.
275
 */
276
277
desc('Starts the Pulse server');
278
task('artisan:pulse:check', artisan('pulse:check'));
279
280
desc('Restarts the Pulse server');
281
task('artisan:pulse:restart', artisan('pulse:restart'));
282
283
desc('Purges all Pulse data from storage');
284
task('artisan:pulse:purge', artisan('pulse:purge'));
285
286
desc('Process incoming Pulse data from the ingest stream');
287
task('artisan:pulse:work', artisan('pulse:work'));
288
289
/**
290
 * Main deploy task.
291
 */
292
desc('Deploys your project');
293
task('deploy', [
294
    'deploy:prepare',
295
    'deploy:vendors',
296
    'artisan:storage:link',
297
    'artisan:config:cache',
298
    'artisan:route:cache',
299
    'artisan:view:cache',
300
    'artisan:event:cache',
301
    'artisan:migrate',
302
    'deploy:publish',
303
]);
304