LabelMakerTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 22
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A createLabel() 0 20 4
1
<?php
2
3
namespace WebTheory\Saveyour\Field\Abstracts;
4
5
use WebTheory\Saveyour\Field\Element\Label;
6
7
trait LabelMakerTrait
8
{
9 3
    protected function createLabel(string $content, array $options): Label
10
    {
11 3
        $label = new Label($content);
12
13 3
        foreach ($options as $option => $value) {
14 3
            $option = str_replace('_', '', $option);
15
16 3
            $set = 'set' . $option;
17 3
            $with = 'with' . $option;
18
19 3
            if (method_exists($label, $set)) {
20 3
                $label->$set($value);
21
            }
22
23 3
            if (method_exists($label, $with)) {
24
                $label->$with($value);
25
            }
26
        }
27
28 3
        return $label;
29
    }
30
}
31