‪TYPO3CMS  10.4
ApplicableConjunction.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 {
25  private ‪$applicables;
26 
27  public static function ‪create(‪Applicable ...‪$applicables): self
28  {
29  return new static(...$applicables);
30  }
31 
32  public function ‪__construct(‪Applicable ...‪$applicables)
33  {
34  $this->applicables = ‪$applicables;
35  }
36 
40  public function ‪getApplicables(): array
41  {
42  return ‪$this->applicables;
43  }
44 
45  public function ‪has(string $type): bool
46  {
47  return !empty($this->‪filter($type));
48  }
49 
54  public function ‪filter(string $type): array
55  {
56  return array_filter(
57  $this->applicables,
58  function (‪Applicable $applicable) use ($type) {
59  return is_a($applicable, $type);
60  }
61  );
62  }
63 
64  public function ‪describe(): string
65  {
66  return sprintf(
67  '{%s}',
68  implode(' | ', array_map([$this, 'describeItem'], $this->applicables))
69  );
70  }
71 
72  private function ‪describeItem(‪Applicable $applicable): string
73  {
74  return $applicable->‪describe();
75  }
76 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\has
‪has(string $type)
Definition: ApplicableConjunction.php:44
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\$applicables
‪Applicable[] $applicables
Definition: ApplicableConjunction.php:24
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\create
‪static create(Applicable ... $applicables)
Definition: ApplicableConjunction.php:26
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\filter
‪Applicable[] filter(string $type)
Definition: ApplicableConjunction.php:53
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Applicable
Definition: Applicable.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Applicable\describe
‪describe()
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\describe
‪describe()
Definition: ApplicableConjunction.php:63
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\getApplicables
‪Applicable[] getApplicables()
Definition: ApplicableConjunction.php:39
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\describeItem
‪describeItem(Applicable $applicable)
Definition: ApplicableConjunction.php:71
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder
Definition: Applicable.php:18
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction
Definition: ApplicableConjunction.php:21
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\__construct
‪__construct(Applicable ... $applicables)
Definition: ApplicableConjunction.php:31