LayoutHelpers::makeRecord()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 13
ccs 10
cts 10
cp 1
rs 9.9666
c 1
b 0
f 0
cc 2
nc 2
nop 1
crap 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