-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted abstract for redundant Host & URI text matchers (#424)
For more details see #424 Key changes: * Extracted abstract `AffixBasedTextMatcher` for redundant Host & URI text matchers * [PHPStan] Aligned baseline with the changes --------- Co-authored-by: Adam Wójs <[email protected]> Co-authored-by: Konrad Oboza <[email protected]>
- Loading branch information
1 parent
0b6ceef
commit 4bed131
Showing
4 changed files
with
63 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/lib/MVC/Symfony/SiteAccess/Matcher/AffixBasedTextMatcher.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Core\MVC\Symfony\SiteAccess\Matcher; | ||
|
||
use Ibexa\Core\MVC\Symfony\SiteAccess\VersatileMatcher; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @phpstan-type TSiteAccessConfigurationArray array{prefix?: string, suffix?: string} | ||
*/ | ||
abstract class AffixBasedTextMatcher extends Regex implements VersatileMatcher | ||
{ | ||
protected readonly string $prefix; | ||
|
||
protected readonly string $suffix; | ||
|
||
abstract protected function buildRegex(): string; | ||
|
||
abstract protected function getMatchedItemNumber(): int; | ||
|
||
/** | ||
* @phpstan-param TSiteAccessConfigurationArray $siteAccessesConfiguration | ||
*/ | ||
public function __construct(private readonly array $siteAccessesConfiguration) | ||
{ | ||
$this->prefix = $this->siteAccessesConfiguration['prefix'] ?? ''; | ||
$this->suffix = $this->siteAccessesConfiguration['suffix'] ?? ''; | ||
|
||
parent::__construct($this->buildRegex(), $this->getMatchedItemNumber()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters