Completed
Pull Request — master (#21)
by Michael
06:34
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
14
class LaravelEfficientUuidServiceProvider extends ServiceProvider
15
{
16
    /**
17
     * Bootstrap any application services.
18
     *
19
     * @return void
20
     */
21 3
    public function boot()
22
    {
23 3
        Schema::registerCustomDoctrineType(
24 3
            BinaryType::class,
25 3
            'efficientuuid',
26 3
            Types::BINARY
27
        );
28 3
    }
29
30
    /**
31
     * Register any application services.
32
     *
33
     * @return void
34
     */
35 3
    public function register()
36
    {
37
        Connection::resolverFor('mysql', function ($connection, $database, $prefix, $config) {
38
            return new MySqlConnection($connection, $database, $prefix, $config);
39 3
        });
40
41
        Connection::resolverFor('sqlite', function ($connection, $database, $prefix, $config) {
42 3
            return new SQLiteConnection($connection, $database, $prefix, $config);
43 3
        });
44
45
        Blueprint::macro('efficientUuid', function ($column) {
46 3
            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...
47 3
        });
48 3
    }
49
}
50