PutHelperServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 1
nop 0
crap 3
1
<?php
2
namespace Djunehor\PutHelper;
3
4
use Illuminate\Support\ServiceProvider;
5
use Illuminate\Support\Facades\Validator;
6
use Illuminate\Http\UploadedFile;
7
8
class PutHelperServiceProvider extends ServiceProvider
9
{
10
11
12
    /**
13
     * Register the application services.
14
     *
15
     * @return void
16
     */
17 5
    public function register()
18
    {
19 5
        $kernel = $this->app->make('Illuminate\Contracts\Http\Kernel');
20 5
        $kernel->pushMiddleware(PutRequestMiddleware::class);
21 5
    }
22
23
    protected $message = ':attribute be a file';
24
25
    /**
26
     * Publishes all the config file this package needs to function.
27
     */
28 5
    public function boot()
29
    {
30
        Validator::extend('put_file', function ($attribute, $value, $parameters, $validator) {
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $validator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31 1
            return (is_object($value) && ($value && get_class($value) == UploadedFile::class));
32 5
        }, $this->message);
33 5
    }
34
35
}
36