LazyPlumber::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
ccs 0
cts 5
cp 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlow;
5
6
/**
7
 * This plumber is laze. It delegates pouring to others using emitter;
8
 * Can be used for concurrency.
9
 */
10
class LazyPlumber
11
{
12
    /**
13
     * @var ProviderInterface
14
     */
15
    private $provider;
16
    /**
17
     * @var PipeLineInterface
18
     */
19
    private $pipeLine;
20
    /**
21
     * @var EmitterInterface
22
     */
23
    private $emitter;
24
25
    public function __construct(
26
        ProviderInterface $provider,
27
        PipeLineInterface $pipeLine,
28
        EmitterInterface $emitter
29
    ) {
30
        $this->provider = $provider;
31
        $this->pipeLine = $pipeLine;
32
        $this->emitter = $emitter;
33
    }
34
35
    public function pour(): void
36
    {
37
        $provider = $this->provider->getCask();
38
        foreach ($provider as $dataBag) {
39
            $this->emitter->emit('pour', $dataBag, $this->pipeLine);
40
        }
41
        $this->emitter->emit('empty_cask');
42
    }
43
}
44