Completed
Push — master ( 1bee2e...dd3854 )
by Fabrice
05:28
created

AggregateExtractor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A addTraversable() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of YaEtl.
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl
6
 * This source file is licensed under the MIT license which you will
7
 * find in the LICENSE file or at https://opensource.org/licenses/MIT
8
 */
9
10
namespace fab2s\YaEtl\Extractors;
11
12
use fab2s\NodalFlow\NodalFlowException;
13
use fab2s\NodalFlow\Nodes\AggregateNode;
14
use fab2s\NodalFlow\Nodes\PayloadNodeAbstract;
15
use fab2s\NodalFlow\Nodes\TraversableNodeInterface;
16
use fab2s\NodalFlow\YaEtlException;
17
use fab2s\YaEtl\YaEtl;
18
19
/**
20
 * class AggregateExtractor
21
 */
22
class AggregateExtractor extends AggregateNode
23
{
24
    /**
25
     * The underlying pseudo Flow
26
     *
27
     * @var YaEtl
28
     */
29
    protected $payload;
30
31
    /**
32
     * AggregateExtractor constructor.
33
     *
34
     * @param $isAReturningVal
35
     *
36
     * @throws NodalFlowException
37
     */
38
    public function __construct($isAReturningVal)
39
    {
40
        PayloadNodeAbstract::__construct(new YaEtl, $isAReturningVal);
41
        $this->isATraversable = true;
42
    }
43
44
    /**
45
     * @param TraversableNodeInterface $node
46
     *
47
     * @throws NodalFlowException
48
     * @throws YaEtlException
49
     *
50
     * @return $this
51
     */
52
    public function addTraversable(TraversableNodeInterface $node)
53
    {
54
        if (!($node instanceof ExtractorInterface)) {
55
            throw new YaEtlException('AggregateExtractor only supports ExtractorInterface Nodes');
56
        }
57
58
        $this->payload->from($node);
59
60
        return $this;
61
    }
62
}
63