AddFieldHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 26
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPriority() 0 4 1
A apply() 0 13 2
1
<?php
2
3
namespace Nayjest\Querying\Handler\PostProcess;
4
5
use Nayjest\Querying\Handler\AbstractHandler;
6
use Nayjest\Querying\Handler\Priority;
7
use Nayjest\Querying\Operation\AddFieldOperation;
8
use Nayjest\Querying\Row\RowInterface;
9
10
class AddFieldHandler extends AbstractHandler
11
{
12
    const PRIORITY = Priority::INITIALIZE_ROWS - 1;
13
14 1
    public function getPriority()
15
    {
16 1
        return self::PRIORITY;
17
    }
18
    /**
19
     * Applies operation to source and returns modified source.
20
     *
21
     */
22 1
    public function apply($dataSource)
23
    {
24
        /** @var AddFieldOperation $operation */
25 1
        $operation = $this->operation;
26 1
        foreach ($dataSource as $row) {
27
            /** @var RowInterface $row */
28 1
            $row->dynamicFieldsRegistry()->add(
29 1
                $operation->getFieldName(),
30 1
                $operation->getCallable()
31 1
            );
32 1
            return $dataSource;
33
        }
34
    }
35
}
36