AggregateExtractor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 40
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addTraversable() 0 9 2
A __construct() 0 5 1
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\AggregateNodeInterface;
15
use fab2s\NodalFlow\Nodes\PayloadNodeAbstract;
16
use fab2s\NodalFlow\Nodes\TraversableNodeInterface;
17
use fab2s\YaEtl\YaEtl;
18
use fab2s\YaEtl\YaEtlException;
19
20
/**
21
 * class AggregateExtractor
22
 */
23
class AggregateExtractor extends AggregateNode
24
{
25
    /**
26
     * The underlying pseudo Flow
27
     *
28
     * @var YaEtl
29
     */
30
    protected $payload;
31
32
    /**
33
     * AggregateExtractor constructor.
34
     *
35
     * @param bool $isAReturningVal
36
     *
37
     * @throws NodalFlowException
38
     */
39
    public function __construct(bool $isAReturningVal)
40
    {
41
        // bypass parent, go to grand pa'. DRY won over KISS
42
        PayloadNodeAbstract::/* @scrutinizer ignore-call */__construct(new YaEtl, $isAReturningVal);
43
        $this->isATraversable = true;
44
    }
45
46
    /**
47
     * @param TraversableNodeInterface $node
48
     *
49
     * @throws NodalFlowException
50
     * @throws YaEtlException
51
     *
52
     * @return static
53
     */
54
    public function addTraversable(TraversableNodeInterface $node): AggregateNodeInterface
55
    {
56
        if (!($node instanceof ExtractorInterface)) {
57
            throw new YaEtlException('AggregateExtractor only supports ExtractorInterface Nodes');
58
        }
59
60
        $this->payload->from($node);
61
62
        return $this;
63
    }
64
}
65