SectionBeforeRead::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 3
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 SectionBeforeRead
22
 *
23
 * Before the readers are called 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 SectionBeforeRead extends Event
31
{
32
    const NAME = 'section.before.read';
33
34
    /** @var \ArrayIterator */
35
    private $data;
36
37
    /** @var ReadOptionsInterface */
38
    private $readOptions;
39
40
    /** @var SectionConfig */
41
    private $sectionConfig;
42
43
    public function __construct(
44
        \ArrayIterator $data,
45
        ReadOptionsInterface $readOptions,
46
        SectionConfig $sectionConfig = null
47
    ) {
48
        $this->data = $data;
49
        $this->readOptions = $readOptions;
50
        $this->sectionConfig = $sectionConfig;
51
    }
52
53
    /**
54
     * @return \ArrayIterator
55
     */
56
    public function getData()
57
    {
58
        return $this->data;
59
    }
60
61
    public function getReadOptions(): ReadOptionsInterface
62
    {
63
        return $this->readOptions;
64
    }
65
66
    public function getSectionConfig(): ?SectionConfig
67
    {
68
        return $this->sectionConfig;
69
    }
70
}
71