Completed
Push — master ( 85994b...9d10cb )
by Dmitry
02:11
created

FieldFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 22
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createByModelAttributes() 0 14 3
1
<?php
2
3
namespace hiapi\query;
4
5
use hiqdev\billing\hiapi\models\ModelInterface;
6
7
class FieldFactory implements FieldFactoryInterface
8
{
9
    /**
10
     * @param ModelInterface $model
11
     * @param $map
12
     * @return Field[]
13
     */
14
    public function createByModelAttributes($model, $map)
15
    {
16
        $result = [];
17
18
        foreach ($map as $attributeName => $sql) {
19
            $attribute = $model->hasAttribute($attributeName)
20
                ? $model->getAttribute($attributeName)
21
                : $model->getRelatedAttribute($attributeName);
22
23
            $result[] = new Field($attributeName, $sql, $attribute);
24
        }
25
26
        return $result;
27
    }
28
}
29