DefaultEnumRowItemBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 17
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 5 1
A renderKeyValue() 0 3 1
A toCamelCase() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace hipanel\rbac\console\converter\formatter;
5
6
use yii\helpers\Inflector;
7
8
class DefaultEnumRowItemBuilder implements EnumRowItemBuilderInterface
9
{
10
    public function build(string $value): string
11
    {
12
        $key = $this->toCamelCase($value);
13
14
        return $this->renderKeyValue($key, $value);
15
    }
16
17
    protected function renderKeyValue(string $key, string $value): string
18
    {
19
        return sprintf('%s"%s" = "%s",', self::IDENTATION, $key, $value);
20
    }
21
22
    protected function toCamelCase(string $value): string
23
    {
24
        return ucwords(Inflector::id2camel(str_replace([':', '.'], '-', $value)));
25
    }
26
}
27