Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge e62b6f1 into 83568db
Browse files Browse the repository at this point in the history
  • Loading branch information
jguittard committed Jan 5, 2019
2 parents 83568db + e62b6f1 commit 8e0bb13
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#97](https://github.com/zendframework/zend-hydrator/pull/97) adds missing `static` keyword to `Zend\Hydrator\NamingStrategy\MapNamingStrategy::createFromAsymmetricMap` while fixing misspelling.

## 3.0.0 - 2018-12-10

Expand Down
2 changes: 1 addition & 1 deletion docs/book/v3/migration.md
Expand Up @@ -207,7 +207,7 @@ three "named constructors":
```php
public static function createFromExtractionMap(array $extractionMap) : MapNamingStrategy;
public static function createFromHydrationMap(array $hydrationMap) : MapNamingStrategy;
public static function createFromAssymetricMap(array $extractionMap, array $hydrationMap) : MapNamingStrategy;
public static function createFromAsymmetricMap(array $extractionMap, array $hydrationMap) : MapNamingStrategy;
```

In the first two cases, the constructor will flip the arrays for purposes of the
Expand Down
4 changes: 2 additions & 2 deletions docs/book/v3/naming-strategy/map-naming-strategy.md
Expand Up @@ -17,7 +17,7 @@ based on the direction:
- When maps are provided for both extraction and hydration, the appropriate map
will be used during extraction and hydration operations. You can create an
instance with this behavior using
`MapNamingStrategy::createFromAssymetricMap(array $extractionMap, array $hydrationStrategy) : MapNamingStrategy`.
`MapNamingStrategy::createFromAsymmetricMap(array $extractionMap, array $hydrationStrategy) : MapNamingStrategy`.

Most of the time, you will want your maps symmetrical; as such, set either a
hydration map or an extraction map, but not both.
Expand Down Expand Up @@ -60,7 +60,7 @@ echo $namingStrategy->hydrate('bash'); // outputs: baz
### Both hydration and extraction maps

```php
$namingStrategy = Zend\Hydrator\NamingStrategy\MapNamingStrategy::createFromAssymetricMap(
$namingStrategy = Zend\Hydrator\NamingStrategy\MapNamingStrategy::createFromAsymmetricMap(
[
'foo' => 'bar',
'baz' => 'bash'
Expand Down
4 changes: 2 additions & 2 deletions src/NamingStrategy/MapNamingStrategy.php
Expand Up @@ -53,7 +53,7 @@ public static function createFromHydrationMap(array $hydrationMap) : self
* @param array<string, string> $extractionMap
* @param array<string, string> $hydrationMap
*/
public function createFromAssymetricMap(array $extractionMap, array $hydrationMap) : self
public static function createFromAsymmetricMap(array $extractionMap, array $hydrationMap) : self
{
$strategy = new self();
$strategy->extractionMap = $extractionMap;
Expand Down Expand Up @@ -84,7 +84,7 @@ public function hydrate(string $name, ?array $data = null) : string
*
* - createFromExtractionMap()
* - createFromHydrationMap()
* - createFromAssymetricMap()
* - createFromAsymmetricMap()
*/
private function __construct()
{
Expand Down
7 changes: 7 additions & 0 deletions test/NamingStrategy/MapNamingStrategyTest.php
Expand Up @@ -124,4 +124,11 @@ public function testHydrateUsesFlippedExtractionMapOnlyExtractionMapProvided()
$strategy = MapNamingStrategy::createFromExtractionMap(['foo' => 'bar']);
$this->assertEquals('foo', $strategy->hydrate('bar'));
}

public function testHydrateAndExtractUseAsymmetricMapProvided()
{
$strategy = MapNamingStrategy::createFromAsymmetricMap(['foo' => 'bar'], ['bat' => 'baz']);
$this->assertEquals('bar', $strategy->extract('foo'));
$this->assertEquals('baz', $strategy->hydrate('bat'));
}
}

0 comments on commit 8e0bb13

Please sign in to comment.