LayoutHelpers   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A makeRecord() 0 13 2
1
<?php
2
3
namespace Claudsonm\Pedi\Support;
4
5
use Claudsonm\Pedi\Structure\Field;
6
use Claudsonm\Pedi\Structure\Record;
7
8
trait LayoutHelpers
9
{
10 9
    public function makeRecord(array $fieldsDefinitions = []): Record
11
    {
12 9
        $record = new Record();
13 9
        foreach ($fieldsDefinitions as $definition) {
14 9
            $field = (new Field())
15 9
                ->setSize($definition['size'])
16 9
                ->setStart($definition['start'])
17 9
                ->setType(new $definition['type']())
18 9
                ->setName($definition['name'] ?? '');
19 9
            $record->add($field);
20
        }
21
22 9
        return $record;
23
    }
24
}
25