Test Failed
Push — master ( f74f09...dc3255 )
by Petr
02:47
created

ColumnsTrait::isColumnNameFromBasic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace kalanis\nested_tree\Support;
4
5
/**
6
 * Trait to work with names of properties within Node class which shall not be added / updated via this package.
7
 */
8
trait ColumnsTrait
9
{
10
    protected function translateColumn(TableSettings $settings, string $name) : string
11
    {
12
        return match ($name) {
13
            'id' => $settings->idColumnName,
14
            'parentId' => $settings->parentIdColumnName,
15
            'level' => $settings->levelColumnName,
16
            'left' => $settings->leftColumnName,
17
            'right' => $settings->rightColumnName,
18
            'position' => $settings->positionColumnName,
19
            default => $name,
20
        };
21
    }
22
23
    protected function isColumnNameFromBasic(string $name) : bool
24
    {
25
        return in_array($name, [
26
            'id',
27
            'childrenIds',
28
            'childrenNodes',
29
        ]);
30
    }
31
32
    protected function isColumnNameFromTree(string $name) : bool
33
    {
34
        return in_array($name, [
35
            'parentId',
36
            'left',
37
            'right',
38
            'level',
39
            'position',
40
        ]);
41
    }
42
}
43