Completed
Push — middleware-wip ( dac6b8...b0158b )
by Romain
05:23
created

Steps   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 2
cbo 2
dl 0
loc 74
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getSettings() 0 4 1
A hasSteps() 0 4 1
A getFirstStepDefinition() 0 4 1
A getEntries() 0 4 1
A getEntry() 0 8 2
A hasEntry() 0 4 1
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\Configuration\AbstractFormzConfiguration;
17
use Romm\Formz\Form\Definition\Step\Step\Step;
18
use Romm\Formz\Form\Definition\Step\Step\StepDefinition;
19
use Romm\Formz\Exceptions\EntryNotFoundException;
20
21
class Steps extends AbstractFormzConfiguration
22
{
23
    /**
24
     * @var \Romm\Formz\Form\Definition\Step\Settings
25
     * @validate NotEmpty
26
     */
27
    protected $settings;
28
29
    /**
30
     * @var \Romm\Formz\Form\Definition\Step\Step\Step[]
31
     */
32
    protected $entries;
33
34
    /**
35
     * @var \Romm\Formz\Form\Definition\Step\Step\StepDefinition
36
     * @validate NotEmpty
37
     */
38
    protected $firstStep;
39
40
    /**
41
     * @return Settings
42
     */
43
    public function getSettings()
44
    {
45
        return $this->settings;
46
    }
47
48
    /**
49
     * @return bool
50
     */
51
    public function hasSteps()
52
    {
53
        return null !== $this->firstStep;
54
    }
55
56
    /**
57
     * @return StepDefinition
58
     */
59
    public function getFirstStepDefinition()
60
    {
61
        return $this->firstStep;
62
    }
63
64
    /**
65
     * @return Step[]
66
     */
67
    public function getEntries()
68
    {
69
        return $this->entries;
70
    }
71
72
    /**
73
     * @param string $name
74
     * @return Step
75
     * @throws EntryNotFoundException
76
     */
77
    public function getEntry($name)
78
    {
79
        if (false === $this->hasEntry($name)) {
80
            throw EntryNotFoundException::stepEntryNotFound($name);
81
        }
82
83
        return $this->entries[$name];
84
    }
85
86
    /**
87
     * @param string $name
88
     * @return bool
89
     */
90
    public function hasEntry($name)
91
    {
92
        return isset($this->entries[$name]);
93
    }
94
}
95