Completed
Push — master ( 8146ea...cf8b86 )
by Stephen
14s queued 12s
created

PostcodesServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JustSteveKing\LaravelPostcodes;
6
7
use GuzzleHttp\Client;
8
use Illuminate\Validation\Rule;
9
use Illuminate\Support\ServiceProvider;
10
use JustSteveKing\LaravelPostcodes\Rules\Postcode;
11
use JustSteveKing\LaravelPostcodes\Service\PostcodeService;
12
13 66
class PostcodesServiceProvider extends ServiceProvider
14
{
15 66
    public function register()
16 66
    {
17 66
        $this->mergeConfigFrom(
18
            __DIR__ . '/../config/services.php',
19
            'services'
20 66
        );
21 66
22 66
        $this->mergeConfigFrom(
23
            __DIR__ . '/../config/postcodes.php',
24
            'postcodes'
25
        );
26 3
27 3
        $this->app->bind(PostcodeService::class, function () {
28
            return new PostcodeService(
29 66
                new Client()
30
            );
31
        });
32 3
33 66
        Rule::macro('postcode', function () {
34 66
            return new Postcode(resolve(PostcodeService::class));
35
        });
36 66
    }
37
}
38