Skip to content

Commit

Permalink
Apply @smnandre's suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Simon André <[email protected]>
  • Loading branch information
Kocal and smnandre authored Nov 20, 2024
1 parent 635bf7c commit 0fc68d9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/Map/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,12 @@ You can interact with the Map by using `LiveAction`
}
}
Then, you can render the map with ``ux_map()`` in your template:
Then, you can render the map with ``ux_map()`` in your component template:

.. code-block:: html+twig

<div{{ attributes.defaults() }}>
{{ ux_map(map, { style: 'height: 300px' }) }}
<div{{ attributes }}>
{{ ux_map(map, {style: 'height: 300px'}) }}
</div>

Then, you can define `Live Actions`_ to interact with the map from the client-side.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(string $message)

public static function missingProviderKey(string $key): self
{
return new self(\sprintf('the provider key ("%s") is missing in the normalized options.', $key));
return new self(\sprintf('the provider key "%s" is missing in the normalized options.', $key));
}

public static function unsupportedProvider(string $provider, array $supportedProviders): self
Expand Down
6 changes: 1 addition & 5 deletions src/Map/src/Live/ComponentWithMapTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ abstract protected function instantiateMap(): Map;

public function getMap(): Map
{
if (null === $this->map) {
$this->map = $this->instantiateMap();
}

return $this->map;
return $this->map ??= $this->instantiateMap();
}

/**
Expand Down
8 changes: 3 additions & 5 deletions src/Map/src/MapOptionsNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ public static function denormalize(array $array): MapOptionsInterface
throw UnableToDenormalizeOptionsException::missingProviderKey(self::KEY_PROVIDER);
}

if (!isset(self::$providers[$provider])) {
throw UnableToDenormalizeOptionsException::unsupportedProvider($provider, array_keys(self::$providers));
}

unset($array[self::KEY_PROVIDER]);

$class = self::$providers[$provider];
if (null === $class = self::$providers[$provider] ?? null) {
throw UnableToDenormalizeOptionsException::unsupportedProvider($provider, array_keys(self::$providers));
}

return $class::fromArray($array);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Map/src/Renderer/AbstractRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ final public function renderMap(Map $map, array $attributes = []): string

private function getMapAttributes(Map $map): array
{
$computeId = fn (array $array) => hash('xxh3', json_encode($array));
$computeId = fn (array $array) => hash('xxh3', json_encode($array, JSON_THROW_ON_ERROR));

$attrs = $map->toArray();

Expand Down

0 comments on commit 0fc68d9

Please sign in to comment.