ComponentGenerator::getTrait()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 10
cc 2
nc 2
nop 1
crap 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
}