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 31
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 110

Importance

Changes 0
Metric Value
cc 10
eloc 15
nc 1
nop 2
dl 0
loc 31
ccs 0
cts 23
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
        // Ensure we warn or fail when a command relies on the ".env" file.
62
        if (in_array('failIfNoEnv', $options) && !test('[ -s {{release_or_current_path}}/.env ]')) {
63
            throw new \Exception('Your .env file is empty! Cannot proceed.');
64
        }
65
66
        if (in_array('skipIfNoEnv', $options) && !test('[ -s {{release_or_current_path}}/.env ]')) {
67
            warning("Your .env file is empty! Skipping...</>");
68
            return;
69
        }
70
71
        // Run the artisan command.
72
        $output = run("{{bin/php}} {{bin/artisan}} $command");
73
74
        // Output the results when appropriate.
75
        if (in_array('showOutput', $options)) {
76
            writeln("<info>$output</info>");
77
        }
78
    };
79
}
80
81
function laravel_version_compare($version, $comparator)
82
{
83
    return version_compare(get('laravel_version'), $version, $comparator);
84
}
85
86
/*
87
 * Maintenance mode.
88
 */
89
90
desc('Puts the application into maintenance / demo mode');
91
task('artisan:down', artisan('down', ['showOutput']));
92
93
desc('Brings the application out of maintenance mode');
94
task('artisan:up', artisan('up', ['showOutput']));
95
96
/*
97
 * Generate keys.
98
 */
99
100
desc('Sets the application key');
101
task('artisan:key:generate', artisan('key:generate'));
102
103
desc('Creates the encryption keys for API authentication');
104
task('artisan:passport:keys', artisan('passport:keys'));
105
106
/*
107
 * Database and migrations.
108
 */
109
110
desc('Seeds the database with records');
111
task('artisan:db:seed', artisan('db:seed --force', ['skipIfNoEnv', 'showOutput']));
112
113
desc('Runs the database migrations');
114
task('artisan:migrate', artisan('migrate --force', ['skipIfNoEnv']));
115
116
desc('Drops all tables and re-run all migrations');
117
task('artisan:migrate:fresh', artisan('migrate:fresh --force', ['skipIfNoEnv']));
118
119
desc('Rollbacks the last database migration');
120
task('artisan:migrate:rollback', artisan('migrate:rollback --force', ['skipIfNoEnv', 'showOutput']));
121
122
desc('Shows the status of each migration');
123
task('artisan:migrate:status', artisan('migrate:status', ['skipIfNoEnv', 'showOutput']));
124
125
/*
126
 * Cache and optimizations.
127
 */
128
129
desc('Flushes the application cache');
130
task('artisan:cache:clear', artisan('cache:clear'));
131
132
desc('Creates a cache file for faster configuration loading');
133
task('artisan:config:cache', artisan('config:cache'));
134
135
desc('Removes the configuration cache file');
136
task('artisan:config:clear', artisan('config:clear'));
137
138
desc('Discovers and cache the application\'s events and listeners');
139
task('artisan:event:cache', artisan('event:cache', ['min' => '5.8.9']));
140
141
desc('Clears all cached events and listeners');
142
task('artisan:event:clear', artisan('event:clear', ['min' => '5.8.9']));
143
144
desc('Lists the application\'s events and listeners');
145
task('artisan:event:list', artisan('event:list', ['showOutput', 'min' => '5.8.9']));
146
147
desc('Cache the framework bootstrap files');
148
task('artisan:optimize', artisan('optimize'));
149
150
desc('Removes the cached bootstrap files');
151
task('artisan:optimize:clear', artisan('optimize:clear'));
152
153
desc('Creates a route cache file for faster route registration');
154
task('artisan:route:cache', artisan('route:cache'));
155
156
desc('Removes the route cache file');
157
task('artisan:route:clear', artisan('route:clear'));
158
159
desc('Lists all registered routes');
160
task('artisan:route:list', artisan('route:list', ['showOutput']));
161
162
desc('Creates the symbolic links configured for the application');
163
task('artisan:storage:link', artisan('storage:link', ['min' => 5.3]));
164
165
desc('Compiles all of the application\'s Blade templates');
166
task('artisan:view:cache', artisan('view:cache', ['min' => 5.6]));
167
168
desc('Clears all compiled view files');
169
task('artisan:view:clear', artisan('view:clear'));
170
171
/**
172
 * Queue and Horizon.
173
 */
174
175
desc('Lists all of the failed queue jobs');
176
task('artisan:queue:failed', artisan('queue:failed', ['showOutput']));
177
178
desc('Flushes all of the failed queue jobs');
179
task('artisan:queue:flush', artisan('queue:flush'));
180
181
desc('Restarts queue worker daemons after their current job');
182
task('artisan:queue:restart', artisan('queue:restart'));
183
184
desc('Starts a master supervisor in the foreground');
185
task('artisan:horizon', artisan('horizon'));
186
187
desc('Deletes all of the jobs from the specified queue');
188
task('artisan:horizon:clear', artisan('horizon:clear --force'));
189
190
desc('Instructs the master supervisor to continue processing jobs');
191
task('artisan:horizon:continue', artisan('horizon:continue'));
192
193
desc('Lists all of the deployed machines');
194
task('artisan:horizon:list', artisan('horizon:list', ['showOutput']));
195
196
desc('Pauses the master supervisor');
197
task('artisan:horizon:pause', artisan('horizon:pause'));
198
199
desc('Terminates any rogue Horizon processes');
200
task('artisan:horizon:purge', artisan('horizon:purge'));
201
202
desc('Gets the current status of Horizon');
203
task('artisan:horizon:status', artisan('horizon:status', ['showOutput']));
204
205
desc('Terminates the master supervisor so it can be restarted');
206
task('artisan:horizon:terminate', artisan('horizon:terminate'));
207
208
desc('Publish all of the Horizon resources');
209
task('artisan:horizon:publish', artisan('horizon:publish'));
210
211
desc('Lists all of the supervisors');
212
task('artisan:horizon:supervisors', artisan('horizon:supervisors', ['showOutput']));
213
214
desc('Deletes metrics for all jobs and queues');
215
task('artisan:horizon:clear-metrics', artisan('horizon:clear-metrics'));
216
217
desc('Stores a snapshot of the queue metrics');
218
task('artisan:horizon:snapshot', artisan('horizon:snapshot'));
219
220
/*
221
 * Scheduler.
222
 */
223
224
desc('Interrupt in-progress schedule:run invocations');
225
task('artisan:schedule:interrupt', artisan('schedule:interrupt'));
226
227
/*
228
 * Telescope.
229
 */
230
231
desc('Clears all entries from Telescope');
232
task('artisan:telescope:clear', artisan('telescope:clear'));
233
234
desc('Prunes stale entries from the Telescope database');
235
task('artisan:telescope:prune', artisan('telescope:prune'));
236
237
/*
238
 * Octane.
239
 */
240
241
desc('Starts the octane server');
242
task('artisan:octane', artisan('octane:start'));
243
244
desc('Reloads the octane server');
245
task('artisan:octane:reload', artisan('octane:reload'));
246
247
desc('Stops the octane server');
248
task('artisan:octane:stop', artisan('octane:stop'));
249
250
desc('Check the status of the octane server');
251
task('artisan:octane:status', artisan('octane:status'));
252
253
/*
254
 * Nova.
255
 */
256
257
desc('Publish all of the Laravel Nova resources');
258
task('artisan:nova:publish', artisan('nova:publish'));
259
260
/*
261
 * Reverb.
262
 */
263
264
desc('Starts the Reverb server');
265
task('artisan:reverb:start', artisan('reverb:start'));
266
267
desc('Restarts the Reverb server');
268
task('artisan:reverb:restart', artisan('reverb:restart'));
269
270
/*
271
 * Pulse.
272
 */
273
274
desc('Starts the Pulse server');
275
task('artisan:pulse:check', artisan('pulse:check'));
276
277
desc('Restarts the Pulse server');
278
task('artisan:pulse:restart', artisan('pulse:restart'));
279
280
desc('Purges all Pulse data from storage');
281
task('artisan:pulse:purge', artisan('pulse:purge'));
282
283
desc('Process incoming Pulse data from the ingest stream');
284
task('artisan:pulse:work', artisan('pulse:work'));
285
286
/**
287
 * Main deploy task.
288
 */
289
desc('Deploys your project');
290
task('deploy', [
291
    'deploy:prepare',
292
    'deploy:vendors',
293
    'artisan:storage:link',
294
    'artisan:config:cache',
295
    'artisan:route:cache',
296
    'artisan:view:cache',
297
    'artisan:event:cache',
298
    'artisan:migrate',
299
    'deploy:publish',
300
]);
301