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

LaravelEfficientUuidServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 6
dl 0
loc 36
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 1
A register() 0 14 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