‪TYPO3CMS  9.5
ApplicableConjunction.php
Go to the documentation of this file.
1 <?php
2 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 {
23  private ‪$applicables;
24 
25  public static function ‪create(‪Applicable ...‪$applicables): self
26  {
27  return new static(...$applicables);
28  }
29 
30  public function ‪__construct(‪Applicable ...‪$applicables)
31  {
32  $this->applicables = ‪$applicables;
33  }
34 
38  public function ‪getApplicables(): array
39  {
40  return ‪$this->applicables;
41  }
42 
43  public function ‪has(string $type): bool
44  {
45  return !empty($this->‪filter($type));
46  }
47 
52  public function ‪filter(string $type): array
53  {
54  return array_filter(
55  $this->applicables,
56  function (‪Applicable $applicable) use ($type) {
57  return is_a($applicable, $type);
58  }
59  );
60  }
61 
62  public function ‪describe(): string
63  {
64  return sprintf(
65  '{%s}',
66  implode(' | ', array_map([$this, 'describeItem'], $this->applicables))
67  );
68  }
69 
70  private function ‪describeItem(‪Applicable $applicable): string
71  {
72  return $applicable->‪describe();
73  }
74 }
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\has
‪has(string $type)
Definition: ApplicableConjunction.php:42
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\$applicables
‪Applicable[] $applicables
Definition: ApplicableConjunction.php:22
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\create
‪static create(Applicable ... $applicables)
Definition: ApplicableConjunction.php:24
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\filter
‪Applicable[] filter(string $type)
Definition: ApplicableConjunction.php:51
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Applicable
Definition: Applicable.php:19
‪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:61
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\getApplicables
‪Applicable[] getApplicables()
Definition: ApplicableConjunction.php:37
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\describeItem
‪describeItem(Applicable $applicable)
Definition: ApplicableConjunction.php:69
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder
Definition: Applicable.php:3
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction
Definition: ApplicableConjunction.php:19
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction\__construct
‪__construct(Applicable ... $applicables)
Definition: ApplicableConjunction.php:29