Test Failed
Push — stable ( de20f1...09eb34 )
by Nuno
01:50
created

helpers.php ➔ info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Container\Container;
4
use LaravelZero\Framework\Contracts\Application as ApplicationContract;
5
6
if (! function_exists('app')) {
7
    /**
8
     * Get the available container instance.
9
     *
10
     * @param  string $make
11
     *
12
     * @return mixed|\Laravel\Lumen\Application
13
     */
14
    function app($make = null)
15
    {
16
        if (is_null($make)) {
17
            return Container::getInstance();
18
        }
19
20
        return Container::getInstance()
21
            ->make($make);
22
    }
23
}
24
25
if (! function_exists('config')) {
26
    /**
27
     * Get / set the specified configuration value.
28
     *
29
     * If an array is passed as the key, we will assume you want to set an array of values.
30
     *
31
     * @param  array|string $key
32
     * @param  mixed $default
33
     *
34
     * @return mixed
35
     */
36
    function config($key = null, $default = null)
37
    {
38
        if (is_null($key)) {
39
            return app('config');
40
        }
41
42
        if (is_array($key)) {
43
            return app('config')->set($key);
44
        }
45
46
        return app('config')->get($key, $default);
47
    }
48
}
49
50
if (! function_exists('event')) {
51
    /**
52
     * Fire an event and call the listeners.
53
     *
54
     * @param  object|string $event
55
     * @param  mixed $payload
56
     * @param  bool $halt
57
     *
58
     * @return array|null
59
     */
60
    function event($event, $payload = [], $halt = false)
61
    {
62
        return app('events')->fire($event, $payload, $halt);
63
    }
64
}
65
66
if (! function_exists('base_path')) {
67
    /**
68
     * Get the path to the base of the install.
69
     *
70
     * @param  string $path
71
     *
72
     * @return string
73
     */
74
    function base_path($path = '')
75
    {
76
        return app()->basePath().($path ? DIRECTORY_SEPARATOR.$path : $path);
77
    }
78
}
79
80
if (! function_exists('confirm')) {
81
    /**
82
     * Confirm a question with the user.
83
     *
84
     * @param  string $question
85
     * @param  bool $default
86
     *
87
     * @return bool
88
     */
89
    function confirm($question, $default = false)
90
    {
91
        return app(ApplicationContract::class)
92
            ->getRunningCommand()
93
            ->confirm($question, $default);
94
    }
95
}
96
97 View Code Duplication
if (! function_exists('ask')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
    /**
99
     * Prompt the user for input.
100
     *
101
     * @param  string $question
102
     * @param  string $default
103
     *
104
     * @return string
105
     */
106
    function ask($question, $default = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
107
    {
108
        return app(ApplicationContract::class)
109
            ->getRunningCommand()
110
            ->ask($question, $default);
111
    }
112
}
113
114
if (! function_exists('anticipate')) {
115
    /**
116
     * Prompt the user for input with auto completion.
117
     *
118
     * @param  string $question
119
     * @param  array $choices
120
     * @param  string $default
121
     *
122
     * @return string
123
     */
124
    function anticipate($question, array $choices, $default = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
125
    {
126
        return app(ApplicationContract::class)
127
            ->getRunningCommand()
128
            ->anticipate($question, $choices, $default);
129
    }
130
}
131
132
if (! function_exists('askWithCompletion')) {
133
    /**
134
     * Prompt the user for input with auto completion.
135
     *
136
     * @param  string $question
137
     * @param  array $choices
138
     * @param  string $default
139
     *
140
     * @return string
141
     */
142
    function askWithCompletion($question, array $choices, $default = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
143
    {
144
        return app(ApplicationContract::class)
145
            ->getRunningCommand()
146
            ->askWithCompletion($question, $choices, $default);
147
    }
148
}
149
150
if (! function_exists('secret')) {
151
    /**
152
     * Prompt the user for input but hide the answer from the console.
153
     *
154
     * @param  string $question
155
     * @param  bool $fallback
156
     *
157
     * @return string
158
     */
159
    function secret($question, $fallback = true)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
160
    {
161
        return app(ApplicationContract::class)
162
            ->getRunningCommand()
163
            ->secret($question, $fallback);
164
    }
165
}
166
167
if (! function_exists('choice')) {
168
    /**
169
     * Give the user a single choice from an array of answers.
170
     *
171
     * @param  string $question
172
     * @param  array $choices
173
     * @param  string $default
174
     * @param  mixed $attempts
175
     * @param  bool $multiple
176
     *
177
     * @return string
178
     */
179
    function choice($question, array $choices, $default = null, $attempts = null, $multiple = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
180
    {
181
        return app(ApplicationContract::class)
182
            ->getRunningCommand()
183
            ->choice($question, $choices, $default, $attempts, $multiple);
184
    }
185
}
186
187 View Code Duplication
if (! function_exists('table')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
188
    /**
189
     * Format input to textual table.
190
     *
191
     * @param  array $headers
192
     * @param  \Illuminate\Contracts\Support\Arrayable|array $rows
193
     * @param  string $style
194
     *
195
     * @return void
196
     */
197
    function table($headers, $rows, $style = 'default')
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
198
    {
199
        app(ApplicationContract::class)
200
            ->getRunningCommand()
201
            ->table($headers, $rows, $style);
202
    }
203
}
204
205 View Code Duplication
if (! function_exists('info')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
206
    /**
207
     * Write a string as information output.
208
     *
209
     * @param  string $string
210
     * @param  null|int|string $verbosity
211
     *
212
     * @return void
213
     */
214
    function info($string, $verbosity = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
215
    {
216
        app(ApplicationContract::class)
217
            ->getRunningCommand()
218
            ->info($string, $verbosity);
219
    }
220
}
221
222 View Code Duplication
if (! function_exists('line')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
223
    /**
224
     * Write a string as standard output.
225
     *
226
     * @param  string $string
227
     * @param  string $style
228
     * @param  null|int|string $verbosity
229
     *
230
     * @return void
231
     */
232
    function line($string, $style = null, $verbosity = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
233
    {
234
        app(ApplicationContract::class)
235
            ->getRunningCommand()
236
            ->line($string, $style, $verbosity);
237
    }
238
}
239
240 View Code Duplication
if (! function_exists('comment')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
241
    /**
242
     * Write a string as comment output.
243
     *
244
     * @param  string $string
245
     * @param  null|int|string $verbosity
246
     *
247
     * @return void
248
     */
249
    function comment($string, $verbosity = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
250
    {
251
        app(ApplicationContract::class)
252
            ->getRunningCommand()
253
            ->comment($string, $verbosity);
254
    }
255
}
256
257 View Code Duplication
if (! function_exists('question')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
258
    /**
259
     * Write a string as question output.
260
     *
261
     * @param  string $string
262
     * @param  null|int|string $verbosity
263
     *
264
     * @return void
265
     */
266
    function question($string, $verbosity = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
267
    {
268
        app(ApplicationContract::class)
269
            ->getRunningCommand()
270
            ->question($string, $verbosity);
271
    }
272
}
273
274 View Code Duplication
if (! function_exists('error')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
275
    /**
276
     * Write a string as error output.
277
     *
278
     * @param  string $string
279
     * @param  null|int|string $verbosity
280
     *
281
     * @return void
282
     */
283
    function error($string, $verbosity = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
284
    {
285
        app(ApplicationContract::class)
286
            ->getRunningCommand()
287
            ->error($string, $verbosity);
288
    }
289
}
290
291 View Code Duplication
if (! function_exists('warn')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
292
    /**
293
     * Write a string as warning output.
294
     *
295
     * @param  string $string
296
     * @param  null|int|string $verbosity
297
     *
298
     * @return void
299
     */
300
    function warn($string, $verbosity = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
301
    {
302
        app(ApplicationContract::class)
303
            ->getRunningCommand()
304
            ->warn($string, $verbosity);
305
    }
306
}
307
308
if (! function_exists('alert')) {
309
    /**
310
     * Write a string in an alert box.
311
     *
312
     * @param  string $string
313
     *
314
     * @return void
315
     */
316
    function alert($string)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
317
    {
318
        app(ApplicationContract::class)
319
            ->getRunningCommand()
320
            ->alert($string);
321
    }
322
}
323
324
if (! function_exists('notify')) {
325
    /**
326
     * Creates a system pop-up notification.
327
     *
328
     * @param string $text
329
     * @param string $body
330
     * @param string|null $icon
331
     *
332
     * @return void
333
     */
334
    function notify(string $text, string $body, $icon = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
335
    {
336
        app(ApplicationContract::class)
337
            ->getRunningCommand()
338
            ->notify($text, $body, $icon);
339
    }
340
}
341