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