ArrayWrite::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlow\Writer;
5
6
use SlayerBirden\DataFlow\DataBagInterface;
7
use SlayerBirden\DataFlow\PipeInterface;
8
use SlayerBirden\DataFlow\IdentificationTrait;
9
10
class ArrayWrite implements PipeInterface
11
{
12
    use IdentificationTrait;
13
    /**
14
     * @var array
15
     */
16
    private $localStorage;
17
    /**
18
     * @var string
19
     */
20
    private $identifier;
21
22 1
    public function __construct(string $id, array &$localStorage)
23
    {
24 1
        $this->identifier = $id;
25 1
        $this->localStorage = &$localStorage;
26 1
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31 1
    public function pass(DataBagInterface $dataBag): DataBagInterface
32
    {
33 1
        $this->localStorage[] = $dataBag->toArray();
34
35 1
        return $dataBag;
36
    }
37
}
38