Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: php-etl/sylius-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e4550805657b777c30b885dec780015224d7d20c
Choose a base ref
..
head repository: php-etl/sylius-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3f412ac3c39fccffe5a9c5234ccef0ab72b8ca76
Choose a head ref
Showing with 11 additions and 11 deletions.
  1. +5 −5 src/Builder/Client.php
  2. +3 −3 src/Validator/ExtractorConfigurationValidator.php
  3. +3 −3 src/Validator/LoaderConfigurationValidator.php
10 changes: 5 additions & 5 deletions src/Builder/Client.php
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ final class Client implements Builder
private ?Node\Expr $httpRequestFactory = null;
private ?Node\Expr $httpStreamFactory = null;
private ?Node\Expr $fileSystem = null;
private ApiType $apiType;
private string $apiType;

public const API_ADMIN_KEY = 'admin';
public const API_SHOP_KEY = 'shop';
@@ -39,7 +39,7 @@ public function withToken(Node\Expr $token, Node\Expr $refreshToken): self
return $this;
}

public function withApiType(ApiType $apiType): self
public function withApiType(string $apiType): self
{
$this->apiType = $apiType;

@@ -136,9 +136,9 @@ public function getNode(): Node\Expr\MethodCall
private function getClientBuilderNode(): Node\Expr\MethodCall
{
$className = match ($this->apiType) {
ApiType::ADMIN => SyliusAdminClientBuilder::class,
ApiType::SHOP => SyliusShopClientBuilder::class,
ApiType::LEGACY => 'Diglin\\Sylius\\ApiClient\\SyliusClientBuilder',
ApiType::ADMIN->value => SyliusAdminClientBuilder::class,
ApiType::SHOP->value => SyliusShopClientBuilder::class,
ApiType::LEGACY->value => 'Diglin\\Sylius\\ApiClient\\SyliusClientBuilder',
};

return new Node\Expr\MethodCall(
6 changes: 3 additions & 3 deletions src/Validator/ExtractorConfigurationValidator.php
Original file line number Diff line number Diff line change
@@ -459,15 +459,15 @@ class ExtractorConfigurationValidator implements ConfigurationValidatorInterface
public static function validate(array $item): array
{
switch($item['api_type']) {
case ApiType::ADMIN:
case ApiType::ADMIN->value:
$endpoints = self::$endpointsAdmin;
$doubleEndpoints = self::$doubleEndpointsAdmin;
break;
case ApiType::SHOP:
case ApiType::SHOP->value:
$endpoints = self::$endpointsShop;
$doubleEndpoints = self::$doubleEndpointsShop;
break;
case ApiType::LEGACY:
case ApiType::LEGACY->value:
$endpoints = self::$endpointsLegacy;
$doubleEndpoints = self::$doubleEndpointsLegacy;
break;
6 changes: 3 additions & 3 deletions src/Validator/LoaderConfigurationValidator.php
Original file line number Diff line number Diff line change
@@ -252,9 +252,9 @@ class LoaderConfigurationValidator implements ConfigurationValidatorInterface
public static function validate(array $item): array
{
$endpoints = match ($item['api_type']) {
ApiType::ADMIN => self::$endpointsAdmin,
ApiType::SHOP => self::$endpointsShop,
ApiType::LEGACY => self::$endpointsLegacy
ApiType::ADMIN->value => self::$endpointsAdmin,
ApiType::SHOP->value => self::$endpointsShop,
ApiType::LEGACY->value => self::$endpointsLegacy
};
if (!\in_array($item['type'], array_keys($endpoints))) {
throw new \InvalidArgumentException(sprintf('the value should be one of [%s], got %s', implode(', ', array_keys($endpoints)), json_encode($item['type'], \JSON_THROW_ON_ERROR)));