Test Setup Failed
Push — master ( 9eb07a...67f9ac )
by
unknown
01:00 queued 21s
created

PaystackServiceProvider::validator()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 2
nc 1
nop 0
1
<?php
2
3
namespace Iamolayemi\Paystack;
4
5
use Illuminate\Support\Facades\Validator;
6
use Illuminate\Support\ServiceProvider;
7
8
class PaystackServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot(): void
14
    {
15
        if ($this->app->runningInConsole()) {
16
            $this->publishes([
17
                __DIR__.'/../config/config.php' => config_path('paystack.php'),
18
            ], 'config');
19
        }
20
        $this->validator();
21
    }
22
23
    /**
24
     * Register the application services.
25
     */
26
    public function register(): void
27
    {
28
        // Automatically apply the package configuration
29
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'paystack');
30
31
        // Register the main class to use with the facade
32
        $this->app->bind('paystack', function () {
33
34
            //validate required credentials
35
            $config = config('paystack');
36
            Validator::make($config, [
37
                'secret_key' => 'required|string',
38
            ])->validate();
39
40
            return new Paystack(config('paystack.secret_key'));
41
        });
42
    }
43
44
45
    private function validator()
46
    {
47
        Validator::macro('required_string', function ($attribute, $value, $arguments) {
0 ignored issues
show
Unused Code introduced by
The parameter $arguments is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

47
        Validator::macro('required_string', function ($attribute, $value, /** @scrutinizer ignore-unused */ $arguments) {

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

Loading history...
48
            return is_string($value) && !empty($value);
49
        });
50
    }
51
52
}
53