WooCommerce
2 weeks ago
AndStrategy.php
2 weeks ago
ConstantDefinedStrategy.php
2 weeks ago
ConstantNotDefinedStrategy.php
2 weeks ago
GetStrategy.php
2 weeks ago
OrStrategy.php
2 weeks ago
PostTypeStrategy.php
2 weeks ago
ShouldShowStrategy.php
2 weeks ago
OrStrategy.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace FSVendor\WPDesk\ShowDecision; |
| 4 | |
| 5 | class OrStrategy implements ShouldShowStrategy |
| 6 | { |
| 7 | /** |
| 8 | * @var ShouldShowStrategy[] |
| 9 | */ |
| 10 | private array $conditions = []; |
| 11 | public function __construct(ShouldShowStrategy $strategy) |
| 12 | { |
| 13 | $this->conditions[] = $strategy; |
| 14 | } |
| 15 | public function addCondition(ShouldShowStrategy $condition): self |
| 16 | { |
| 17 | $this->conditions[] = $condition; |
| 18 | return $this; |
| 19 | } |
| 20 | public function shouldDisplay(): bool |
| 21 | { |
| 22 | foreach ($this->conditions as $condition) { |
| 23 | if ($condition->shouldDisplay()) { |
| 24 | return \true; |
| 25 | } |
| 26 | } |
| 27 | return \false; |
| 28 | } |
| 29 | } |
| 30 |