RecaptchaServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 1
A register() 0 8 1
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