ColumnsTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 19
c 1
b 0
f 0
dl 0
loc 32
ccs 23
cts 23
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isColumnNameFromBasic() 0 6 1
A isColumnNameFromTree() 0 8 1
A translateColumn() 0 10 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 3
    protected function translateColumn(TableSettings $settings, string $name) : string
11
    {
12 3
        return match ($name) {
13 1
            'id' => $settings->idColumnName,
14 2
            'parentId' => $settings->parentIdColumnName,
15 1
            'level' => $settings->levelColumnName,
16 1
            'left' => $settings->leftColumnName,
17 1
            'right' => $settings->rightColumnName,
18 1
            'position' => $settings->positionColumnName,
19 3
            default => $name,
20 3
        };
21
    }
22
23 2
    protected function isColumnNameFromBasic(string $name) : bool
24
    {
25 2
        return in_array($name, [
26 2
            'id',
27 2
            'childrenIds',
28 2
            'childrenNodes',
29 2
        ]);
30
    }
31
32 1
    protected function isColumnNameFromTree(string $name) : bool
33
    {
34 1
        return in_array($name, [
35 1
            'parentId',
36 1
            'left',
37 1
            'right',
38 1
            'level',
39 1
            'position',
40 1
        ]);
41
    }
42
}
43