Completed
Push — feature/middleware ( 864c18 )
by Romain
03:21
created

Steps::hasSteps()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * 2017 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 FormZ project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\Form\Definition\Step;
15
16
use Romm\Formz\Exceptions\EntryNotFoundException;
17
use Romm\Formz\Form\Definition\AbstractFormDefinitionComponent;
18
use Romm\Formz\Form\Definition\Step\Step\Step;
19
use Romm\Formz\Form\Definition\Step\Step\StepDefinition;
20
21
class Steps extends AbstractFormDefinitionComponent
22
{
23
    /**
24
     * @var \Romm\Formz\Form\Definition\Step\Settings
25
     */
26
    protected $settings;
27
28
    /**
29
     * @var \Romm\Formz\Form\Definition\Step\Step\Step[]
30
     */
31
    protected $entries;
32
33
    /**
34
     * @var \Romm\Formz\Form\Definition\Step\Step\StepDefinition
35
     * @validate NotEmpty
36
     */
37
    protected $firstStep;
38
39
    /**
40
     * @return Settings
41
     */
42
    public function getSettings()
43
    {
44
        return $this->settings;
45
    }
46
47
    /**
48
     * @return bool
49
     */
50
    public function hasSteps()
51
    {
52
        return null !== $this->firstStep;
53
    }
54
55
    /**
56
     * @return StepDefinition
57
     */
58
    public function getFirstStepDefinition()
59
    {
60
        return $this->firstStep;
61
    }
62
63
    /**
64
     * @return Step[]
65
     */
66
    public function getEntries()
67
    {
68
        return $this->entries;
69
    }
70
71
    /**
72
     * @param string $name
73
     * @return Step
74
     * @throws EntryNotFoundException
75
     */
76
    public function getEntry($name)
77
    {
78
        if (false === $this->hasEntry($name)) {
79
            throw EntryNotFoundException::stepEntryNotFound($name);
80
        }
81
82
        return $this->entries[$name];
83
    }
84
85
    /**
86
     * @param string $name
87
     * @return bool
88
     */
89
    public function hasEntry($name)
90
    {
91
        return isset($this->entries[$name]);
92
    }
93
}
94