AbstractSystemModelTypeFactory::parseArgs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Leonidas\Library\System\Model;
4
5
class AbstractSystemModelTypeFactory
6
{
7
    protected string $prefix;
8
9
    public function __construct(string $prefix = '')
10
    {
11
        $this->prefix = $prefix;
12
    }
13
14
    protected function parseArgs($args): array
15
    {
16
        $labels = $args['labels'] ?? [];
17
        $plural = $args['plural'] ?? null;
18
        $single = $args['singular'] ?? null;
19
20
        $args['plural'] = $plural ?? $labels['name'];
21
        $args['singular'] = $single ?? $labels['singular_name'] ?? $plural;
22
23
        return $args;
24
    }
25
26
    protected function prefix(string $string)
27
    {
28
        return $this->prefix . $string;
29
    }
30
}
31