-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\TwigHooks\Hook\Normalizer\Prefix; | ||
|
||
use Sylius\TwigHooks\Hook\Normalizer\Name\NameNormalizerInterface; | ||
|
||
final class CompositePrefixNormalizer implements PrefixNormalizerInterface | ||
{ | ||
/** @var array<PrefixNormalizerInterface> */ | ||
private readonly array $prefixNormalizers; | ||
|
||
/** | ||
* @param iterable<PrefixNormalizerInterface> $prefixNormalizers | ||
*/ | ||
public function __construct(iterable $prefixNormalizers) | ||
{ | ||
$this->prefixNormalizers = $prefixNormalizers instanceof \Traversable ? iterator_to_array($prefixNormalizers) : $prefixNormalizers; | ||
} | ||
|
||
public function normalize(string $prefix): string | ||
{ | ||
$normalizedPrefix = $prefix; | ||
|
||
foreach ($this->prefixNormalizers as $prefixNormalizer) { | ||
$normalizedPrefix = $prefixNormalizer->normalize($normalizedPrefix); | ||
} | ||
|
||
return $normalizedPrefix; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\TwigHooks\Hook\Normalizer\Prefix; | ||
|
||
interface PrefixNormalizerInterface | ||
{ | ||
public function normalize(string $prefix): string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\TwigHooks\Hookable\Metadata; | ||
|
||
use Sylius\TwigHooks\Bag\DataBagInterface; | ||
use Sylius\TwigHooks\Bag\ScalarDataBagInterface; | ||
use Sylius\TwigHooks\Hook\Metadata\HookMetadata; | ||
use Sylius\TwigHooks\Hook\Normalizer\Prefix\PrefixNormalizerInterface; | ||
|
||
final class HookableMetadataFactory implements HookableMetadataFactoryInterface | ||
{ | ||
public function __construct( | ||
private readonly PrefixNormalizerInterface $prefixNormalizer | ||
) { | ||
} | ||
|
||
public function create( | ||
Check failure on line 19 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactory.php GitHub Actions / Continuous Integration (PHP 8.1 / Symfony ^5.4)
Check failure on line 19 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactory.php GitHub Actions / Continuous Integration (PHP 8.1 / Symfony ^6.4)
Check failure on line 19 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactory.php GitHub Actions / Continuous Integration (PHP 8.2 / Symfony ^5.4)
Check failure on line 19 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactory.php GitHub Actions / Continuous Integration (PHP 8.2 / Symfony ^6.4)
Check failure on line 19 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactory.php GitHub Actions / Continuous Integration (PHP 8.3 / Symfony ^5.4)
Check failure on line 19 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactory.php GitHub Actions / Continuous Integration (PHP 8.3 / Symfony ^6.4)
|
||
HookMetadata $hookMetadata, | ||
DataBagInterface $context, | ||
ScalarDataBagInterface $configuration, | ||
array $prefixes = [], | ||
): HookableMetadata { | ||
$prefixes = array_map([$this->prefixNormalizer, 'normalize'], $prefixes); | ||
|
||
return new HookableMetadata($hookMetadata, $context, $configuration, $prefixes); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\TwigHooks\Hookable\Metadata; | ||
|
||
use Sylius\TwigHooks\Bag\DataBagInterface; | ||
use Sylius\TwigHooks\Bag\ScalarDataBagInterface; | ||
use Sylius\TwigHooks\Hook\Metadata\HookMetadata; | ||
|
||
interface HookableMetadataFactoryInterface | ||
{ | ||
public function create(HookMetadata $hookMetadata, DataBagInterface $context, ScalarDataBagInterface $configuration, array $prefixes = [],): HookableMetadata; | ||
Check failure on line 13 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactoryInterface.php GitHub Actions / Continuous Integration (PHP 8.1 / Symfony ^5.4)
Check failure on line 13 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactoryInterface.php GitHub Actions / Continuous Integration (PHP 8.1 / Symfony ^6.4)
Check failure on line 13 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactoryInterface.php GitHub Actions / Continuous Integration (PHP 8.2 / Symfony ^5.4)
Check failure on line 13 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactoryInterface.php GitHub Actions / Continuous Integration (PHP 8.2 / Symfony ^6.4)
Check failure on line 13 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactoryInterface.php GitHub Actions / Continuous Integration (PHP 8.3 / Symfony ^5.4)
Check failure on line 13 in src/TwigHooks/src/Hookable/Metadata/HookableMetadataFactoryInterface.php GitHub Actions / Continuous Integration (PHP 8.3 / Symfony ^6.4)
|
||
} |