DefaultEnumRowItemBuilder::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 5
rs 10
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