Completed
Pull Request — master (#21)
by Michael
06:31
created

LaravelEfficientUuidServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Dyrynda\Database;
4
5
use Doctrine\DBAL\Types\Types;
6
use Doctrine\DBAL\Types\BinaryType;
7
use Illuminate\Database\Connection;
8
use Illuminate\Support\Facades\Schema;
9
use Illuminate\Support\ServiceProvider;
10
use Illuminate\Database\Schema\Blueprint;
11
use Dyrynda\Database\Connection\MySqlConnection;
12
use Dyrynda\Database\Connection\SQLiteConnection;
13
use Dyrynda\Database\Connection\PostgresConnection;
14
15
class LaravelEfficientUuidServiceProvider extends ServiceProvider
16
{
17
    /**
18
     * Bootstrap any application services.
19
     *
20
     * @return void
21
     */
22 4
    public function boot()
23
    {
24 4
        Schema::registerCustomDoctrineType(
25 4
            BinaryType::class,
26 4
            'efficientuuid',
27 4
            Types::BINARY
28
        );
29 4
    }
30
31
    /**
32
     * Register any application services.
33
     *
34
     * @return void
35
     */
36 4
    public function register()
37
    {
38
        Connection::resolverFor('mysql', function ($connection, $database, $prefix, $config) {
39
            return new MySqlConnection($connection, $database, $prefix, $config);
40 4
        });
41
42
        Connection::resolverFor('postgres', function ($connection, $database, $prefix, $config) {
43
            return new PostgresConnection($connection, $database, $prefix, $config);
44 4
        });
45
        
46
        Connection::resolverFor('sqlite', function ($connection, $database, $prefix, $config) {
47 4
            return new SQLiteConnection($connection, $database, $prefix, $config);
48 4
        });
49
50
        Blueprint::macro('efficientUuid', function ($column) {
51 4
            return $this->addColumn('efficientUuid', $column);
0 ignored issues
show
Bug introduced by
The method addColumn() does not seem to exist on object<Dyrynda\Database\...entUuidServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52 4
        });
53 4
    }
54
}
55