SectionDataRead   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSectionConfig() 0 3 1
A getReadOptions() 0 3 1
A __construct() 0 8 1
A getData() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the SexyField package.
5
 *
6
 * (c) Dion Snoeijen <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare (strict_types = 1);
13
14
namespace Tardigrades\SectionField\Event;
15
16
use Symfony\Component\EventDispatcher\Event;
17
use Tardigrades\SectionField\Service\ReadOptionsInterface;
18
use Tardigrades\SectionField\ValueObject\SectionConfig;
19
20
/**
21
 * Class SectionDataRead
22
 *
23
 * After reading data from the readers, this event gives the opportunity to:
24
 * - prefill the data array iterator
25
 * - use / manipulate read options
26
 * - use / manipulate section config
27
 *
28
 * @package Tardigrades\SectionField\Event
29
 */
30
class SectionDataRead extends Event
31
{
32
    const NAME = 'section.data.read';
33
34
    /** @var \ArrayIterator */
35
    private $data;
36
37
    /** @var ReadOptionsInterface */
38
    private $readOptions;
39
40
    /** @var ?SectionConfig */
41
    private $sectionConfig;
42
43
    /**
44
     * SectionDataRead constructor.
45
     * @param \ArrayIterator $data
46
     * @param ReadOptionsInterface $readOptions
47
     * @param SectionConfig $sectionConfig
48
     */
49
    public function __construct(
50
        \ArrayIterator $data,
51
        ReadOptionsInterface $readOptions,
52
        SectionConfig $sectionConfig = null
53
    ) {
54
        $this->data = $data;
55
        $this->readOptions = $readOptions;
56
        $this->sectionConfig = $sectionConfig;
57
    }
58
59
    /**
60
     * The array containing data from the readers
61
     *
62
     * @return \ArrayIterator
63
     */
64
    public function getData(): \ArrayIterator
65
    {
66
        return $this->data;
67
    }
68
69
    /**
70
     * Get read options for manipulation or other actions
71
     *
72
     * @return ReadOptionsInterface
73
     */
74
    public function getReadOptions(): ReadOptionsInterface
75
    {
76
        return $this->readOptions;
77
    }
78
79
    /**
80
     * Get section config for manipulation or other actions
81
     *
82
     * @return null|SectionConfig
83
     */
84
    public function getSectionConfig(): ?SectionConfig
85
    {
86
        return $this->sectionConfig;
87
    }
88
}
89