MiniCrudPolymorphic::skipField()   B
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 15
Ratio 93.75 %

Code Coverage

Tests 5
CRAP Score 6.3183

Importance

Changes 0
Metric Value
cc 5
eloc 8
nc 4
nop 2
dl 15
loc 16
ccs 5
cts 8
cp 0.625
crap 6.3183
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace Anavel\Crud\Abstractor\Eloquent\Relation;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class MiniCrudPolymorphic extends MiniCrud
8
{
9
    protected $compatibleEloquentRelations = [
10
        'Illuminate\Database\Eloquent\Relations\MorphMany',
11
    ];
12
13 1 View Code Duplication
    protected function skipField($columnName, $key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
    {
15 1
        if ($columnName === $this->eloquentRelation->getPlainForeignKey()) {
16
            return true;
17
        }
18
19 1
        if ($columnName === $this->eloquentRelation->getPlainMorphType()) {
20
            return true;
21
        }
22
23 1
        if ($key === 'emptyResult' && ($columnName === $this->eloquentRelation->getParent()->getKeyName())) {
24
            return true;
25
        }
26
27 1
        return false;
28
    }
29
30 1
    protected function setKeys(Model $relationModel)
31
    {
32 1
        $relationModel->setAttribute($this->eloquentRelation->getForeignKey(), $this->relatedModel->id);
33 1
        $relationModel->setAttribute($this->eloquentRelation->getPlainMorphType(), $this->eloquentRelation->getMorphClass());
34 1
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getDisplayType()
40
    {
41
        return self::DISPLAY_TYPE_TAB;
42
    }
43
}
44