Test Failed
Push — master ( 180f30...aa27d2 )
by Terzi
04:24
created

NumberDetector::detect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Terranet\Administrator\Field\Detectors;
4
5
use Doctrine\DBAL\Schema\Column;
6
use Doctrine\DBAL\Types\BigIntType;
7
use Doctrine\DBAL\Types\DecimalType;
8
use Doctrine\DBAL\Types\FloatType;
9
use Doctrine\DBAL\Types\IntegerType;
10
use Doctrine\DBAL\Types\SmallIntType;
11
use Illuminate\Database\Eloquent\Model;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Model was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Terranet\Administrator\Field\Number;
13
use Terranet\Administrator\Field\Text;
14
15
class NumberDetector extends AbstractDetector
16
{
17
    /**
18
     * Authorize execution.
19
     *
20
     * @param  string  $column
21
     * @param  Column  $metadata
22
     * @param  Model  $model
23
     *
24
     * @return bool
25
     */
26
    protected function authorize(string $column, Column $metadata, Model $model): bool
27
    {
28
        $class = get_class($metadata->getType());
29
30
        return in_array($class, [
31
            IntegerType::class,
32
            DecimalType::class,
33
            FloatType::class,
34
            BigIntType::class,
35
            SmallIntType::class,
36
        ]);
37
    }
38
39
    /**
40
     * Detect field class.
41
     *
42
     * @param  string  $column
43
     * @param  Column  $metadata
44
     * @param  Model  $model
45
     *
46
     * @return mixed
47
     */
48
    protected function detect(string $column, Column $metadata, Model $model)
49
    {
50
        return Number::class;
51
    }
52
}
53