Passed
Push — master ( 4c5faf...429320 )
by Chris
04:23
created

LabelMaker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 90.91%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 25
ccs 10
cts 11
cp 0.9091
rs 10
wmc 4

1 Method

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