ComponentFactory
1 month ago
Control
1 month ago
Type
1 month ago
AttributeCollection.php
1 month ago
AttributeFactory.php
1 month ago
Children.php
1 month ago
Component.php
1 month ago
ComponentBuilder.php
1 month ago
ComponentCollection.php
1 month ago
ComponentFactory.php
1 month ago
ConditionalComponentFactory.php
1 month ago
ConditionalComponentFactoryCollection.php
1 month ago
Config.php
1 month ago
ConfigCollection.php
1 month ago
ConfigFactory.php
1 month ago
Context.php
1 month ago
Control.php
1 month ago
DefaultSettingsBuilder.php
1 month ago
Encoder.php
1 month ago
Formatter.php
1 month ago
FormatterCollection.php
1 month ago
Control.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Setting; |
| 6 | |
| 7 | use AC\Expression\NullSpecification; |
| 8 | use AC\Expression\Specification; |
| 9 | use AC\Setting\Control\Input; |
| 10 | |
| 11 | class Control |
| 12 | { |
| 13 | |
| 14 | private Input $input; |
| 15 | |
| 16 | private ?Specification $conditions; |
| 17 | |
| 18 | public function __construct( |
| 19 | Input $input, |
| 20 | ?Specification $conditions = null |
| 21 | ) { |
| 22 | $this->input = $input; |
| 23 | $this->conditions = $conditions; |
| 24 | } |
| 25 | |
| 26 | public function get_input(): Input |
| 27 | { |
| 28 | return $this->input; |
| 29 | } |
| 30 | |
| 31 | public function get_name(): string |
| 32 | { |
| 33 | return $this->input->get_name(); |
| 34 | } |
| 35 | |
| 36 | public function has_conditions(): bool |
| 37 | { |
| 38 | return $this->conditions !== null; |
| 39 | } |
| 40 | |
| 41 | public function get_conditions(): Specification |
| 42 | { |
| 43 | if ( ! $this->has_conditions()) { |
| 44 | return new NullSpecification(); |
| 45 | } |
| 46 | |
| 47 | return $this->conditions; |
| 48 | } |
| 49 | |
| 50 | } |