Completed
Push — master ( 3380b3...070995 )
by Action
02:30
created

UnitPayServiceProvider::testingEnv()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 0
1
<?php
2
3
namespace ActionM\UnitPay;
4
5
use Illuminate\Support\Facades\App;
6
use Illuminate\Support\ServiceProvider;
7
use ActionM\UnitPay\Exceptions\InvalidConfiguration;
8
9
class UnitPayServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     */
14
    public function boot()
15
    {
16
        $this->publishes([
17
            __DIR__.'/../config/unitpay.php' => config_path('unitpay.php'),
18
        ], 'config');
19
20
        $this->publishes([
21
            __DIR__.'/../resources/views' => base_path('resources/views/vendor/unitpay'),
22
        ], 'views');
23
24
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'unitpay');
25
26
        $this->testingEnv();
27
    }
28
29
    /**
30
     * Register the application services.
31
     */
32
    public function register()
33
    {
34
        $this->mergeConfigFrom(__DIR__.'/../config/unitpay.php', 'unitpay');
35
36
        $this->app['events']->subscribe(UnitPayNotifier::class);
37
38
        $this->app->singleton('unitpay', function () {
39
            return $this->app->make('ActionM\UnitPay\UnitPay');
40
        });
41
42
        $this->app->alias('unitpay', 'UnitPay');
43
44
        $this->app->singleton(UnitPayNotifier::class);
45
    }
46
47
    /**
48
     * Not check config if testing env.
49
     * @throws InvalidConfiguration
50
     */
51
    public function testingEnv()
52
    {
53
        if (! App::environment('testing')) {
1 ignored issue
show
Unused Code introduced by
The call to App::environment() has too many arguments starting with 'testing'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
54
            $callable = config('unitpay.searchOrderFilter');
55
56
            if (! is_callable($callable)) {
57
                throw InvalidConfiguration::searchOrderFilterInvalid();
58
            }
59
60
            $callable = config('unitpay.paidOrderFilter');
61
62
            if (! is_callable($callable)) {
63
                throw InvalidConfiguration::orderPaidFilterInvalid();
64
            }
65
        }
66
    }
67
}
68