Passed
Push — master ( 9fe3b0...ea33af )
by belamov
02:37 queued 21s
created

setCustomResolverForPgsql()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Belamov\PostgresRange;
4
5
use Illuminate\Database\Connection;
6
use Illuminate\Support\Collection;
7
use Illuminate\Support\ServiceProvider;
8
9
class PostgresRangeServiceProvider extends ServiceProvider
10
{
11
    public function register()
12
    {
13
        $this->setCustomResolverForPgsql();
14
    }
15
16
    protected function setCustomResolverForPgsql(): void
17
    {
18
        Connection::resolverFor('pgsql', function ($connection, $database, $prefix, $config) {
19
            return new PostgresConnection($connection, $database, $prefix, $config);
20
        });
21
    }
22
23
    /**
24
     * Bootstrap the application services.
25
     */
26
    public function boot(): void
27
    {
28
        Collection::make(glob(__DIR__.'/Macros/*.php'))->mapWithKeys(
29
            static function ($path) {
30
                return [$path => pathinfo($path, PATHINFO_FILENAME)];
31
            }
32
        )->each(
33
            static function ($macro, $path) {
34
                require_once $path;
35
            }
36
        );
37
    }
38
}
39