Passed
Push — develop ( 9e1471...604a29 )
by Luca
05:40 queued 03:31
created

AdsenseServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
/**
4
 * Google Adsense Ads for Laravel.
5
 *
6
 * Package for easily including Google Adsense Ad units
7
 * in Laravel and Lumen.
8
 *
9
 * @developer Crypto Technology srl <https://cryptotech.srl/>
10
 *
11
 * @copyright Copyright (c) 2019 Crypto Technology srl
12
 * @license   MIT
13
 *
14
 * Copyright (c) 2016 Galen Han
15
 * Copyright (c) 2019 Crypto Technology srl
16
 *
17
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
18
 * this software and associated documentation files (the "Software"), to deal in
19
 * the Software without restriction, including without limitation the rights to
20
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
21
 * the Software, and to permit persons to whom the Software is furnished to do so,
22
 * subject to the following conditions:
23
 *
24
 * The above copyright notice and this permission notice shall be included in all
25
 * copies or substantial portions of the Software.
26
 *
27
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
29
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
30
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
31
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
 */
34
35
declare(strict_types=1);
36
37
namespace CryptoTech\Laravel\Adsense\Providers;
38
39
use CryptoTech\Laravel\Adsense\AdsenseBuilder;
40
use Illuminate\Support\ServiceProvider;
41
/** @scrutinizer ignore-type */ use Laravel\Lumen\Application as LumenApplication;
42
43
/**
44
 * Class AdsenseServiceProvider.
45
 *
46
 * @see \Illuminate\Support\ServiceProvider
47
 */
48
class AdsenseServiceProvider extends ServiceProvider
49
{
50
    /**
51
     * Bootstrap any application services.
52
     */
53 1
    public function boot(): void
54
    {
55 1
        if ($this->app instanceof LumenApplication) {
56
            /** @scrutinizer ignore-call */ $this->app->configure('adsense');
57
        } else {
58 1
            $this->publishes([
59 1
                $this->getConfigFile() => config_path('adsense-ads.php'),
60 1
            ], 'config');
61
        }
62
63 1
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'adsense');
64 1
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 1
    public function register(): void
70
    {
71 1
        $this->mergeConfigFrom(
72 1
            $this->getConfigFile(),
73 1
            'adsense'
74
        );
75
76
        $this->app->bind(AdsenseBuilder::class, function () {
77
            return new AdsenseBuilder();
78 1
        });
79 1
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function provides(): array
85
    {
86
        return [
87
            'adsense',
88
        ];
89
    }
90
91
    /**
92
     * Return the path of configuration file.
93
     */
94 1
    protected function getConfigFile(): string
95
    {
96 1
        return __DIR__.'/../resources/config/adsense-ads.php';
97
    }
98
}
99