Completed
Push — master ( 72a5c2...ae9e87 )
by Valerka
08:45
created

RecaptchaServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PheRum\Recaptcha;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class RecaptchaServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap the application events.
11
     *
12
     * @return void
13
     */
14
    public function boot()
15
    {
16
        $this->loadViewsFrom(__DIR__ . '/resources/views', 'pherum');
17
        
18
        $this->publishes([
19
            __DIR__ . '/config/recaptcha.php' => config_path('recaptcha.php'),
20
        ], 'config');
21
        
22
        $this->app->validator->extend('recaptcha', function ($attribute, $value) {
0 ignored issues
show
Bug introduced by
Accessing validator on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
Unused Code introduced by
The parameter $attribute 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 $value 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...
23
            return app('recaptcha')->verify(app('request'));
24
        });
25
    }
26
    
27
    /**
28
     * Register the application services.
29
     *
30
     * @return void
31
     */
32
    public function register()
33
    {
34
        $this->mergeConfigFrom(__DIR__ . '/config/recaptcha.php', 'recaptcha');
35
        
36
        $this->app->bind('recaptcha', function () {
37
            return new Recaptcha(config('recaptcha'));
38
        });
39
    }
40
}
41