Passed
Push — master ( f916ce...b72f24 )
by belamov
11:20 queued 10s
created

BluePrintMacros   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 16
dl 0
loc 24
rs 10
c 1
b 1
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 13 2
1
<?php
2
3
namespace Belamov\PostgresRange\Macros;
4
5
use Illuminate\Database\Schema\Blueprint;
6
7
class BluePrintMacros
8
{
9
    private array $columnTypes = [
10
        ['dateRange', 'daterange'],
11
        ['timestampRange', 'tsrange'],
12
        ['floatRange', 'numrange'],
13
        ['integerRange', 'int4range'],
14
        ['bigIntegerRange', 'int8range'],
15
        ['timeRange', 'timerange'],
16
    ];
17
18
    public function register(): void
19
    {
20
        foreach ($this->columnTypes as [$columnTypeForMacro, $columnTypeForPostgres]) {
21
            Blueprint::macro(
22
                $columnTypeForMacro,
23
                fn(string $columnName) => $this->addColumn($columnTypeForPostgres, $columnName)
0 ignored issues
show
Bug introduced by
The method addColumn() does not exist on Belamov\PostgresRange\Macros\BluePrintMacros. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
                fn(string $columnName) => $this->/** @scrutinizer ignore-call */ addColumn($columnTypeForPostgres, $columnName)

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...
24
            );
25
        }
26
27
        Blueprint::macro('excludeRangeOverlapping', function ($columnName, ...$additionalColumns) {
28
            return $this->addCommand('excludeRangeOverlapping', [
0 ignored issues
show
Bug introduced by
The method addCommand() does not exist on Belamov\PostgresRange\Macros\BluePrintMacros. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
            return $this->/** @scrutinizer ignore-call */ addCommand('excludeRangeOverlapping', [

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...
29
                'column' => $columnName,
30
                'additionalColumns' => $additionalColumns,
31
            ]);
32
        });
33
    }
34
}
35
36
37