TsObjectGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 6 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace hipanel\rbac\console\converter;
5
6
use Laminas\Code\Generator\AbstractGenerator;
7
8
final class TsObjectGenerator extends AbstractGenerator
9
{
10
    private string $name;
11
    private array $items;
12
13
    public function __construct(string $name, array $items)
14
    {
15
        $this->name = $name;
16
        $this->items = $items;
17
    }
18
19
    public function generate(): string
20
    {
21
        return sprintf(<<<JS
22
export const %s%s= %s;
23
JS
24
        , $this->name, $this->indentation, json_encode($this->items));
25
    }
26
}
27