ComponentGenerator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 13
c 2
b 0
f 0
dl 0
loc 32
ccs 15
cts 15
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getClassModel() 0 7 1
A getImplementation() 0 5 1
A getTrait() 0 12 2
1
<?php  namespace Distilleries\Expendable\Console\Lib\Generators;
2
3
class ComponentGenerator extends \Kris\LaravelFormBuilder\Console\FormGenerator {
4
5 12
    public function getClassModel($model)
6
    {
7 12
        $model = preg_split('/\//i', $model);
8 12
        $model = last($model);
0 ignored issues
show
Bug introduced by
It seems like $model can also be of type false; however, parameter $array of last() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

8
        $model = last(/** @scrutinizer ignore-type */ $model);
Loading history...
9 12
        $model = preg_replace('/\.php/i', '', $model);
10
11 12
        return '\\'.$model;
12
13
    }
14
15 12
    public function getTrait($states)
16
    {
17 12
        $result = '';
18
19 12
        foreach ($states as $state)
20
        {
21 8
            $state = preg_replace('/Contracts/i', 'States', $state);
22 8
            $state = preg_replace('/Contract/i', 'Trait', $state);
23 8
            $result .= 'use '.$state.';'."\n";
24
        }
25
26 12
        return $result;
27
28
    }
29
30 12
    public function getImplementation($states)
31
    {
32 12
        $result = 'implements '.join(', ', $states);
33
34 12
        return $result;
35
36
    }
37
}