Skip to content

Commit

Permalink
Removed Translate strategy and accompanying test.
Browse files Browse the repository at this point in the history
Renamed Copy* strategy invoke parameters data -> record.
  • Loading branch information
Paul committed Jun 12, 2017
1 parent b0a28a0 commit fb31788
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 84 deletions.
10 changes: 5 additions & 5 deletions src/Strategy/Copy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ class Copy extends Delegate
const PATH_SEPARATOR = '->';

/**
* @param mixed $data
* @param mixed $record
* @param mixed $context
*
* @return mixed
*/
public function __invoke($data, $context = null)
public function __invoke($record, $context = null)
{
if (!is_array($data)) {
if (!is_array($record)) {
return null;
}

if (!is_array($path = parent::__invoke($data, $context))) {
if (!is_array($path = parent::__invoke($record, $context))) {
$path = explode(self::PATH_SEPARATOR, $path);
}

return $path ? ArrayWalker::walk($data, $path) : null;
return $path ? ArrayWalker::walk($record, $path) : null;
}
}
2 changes: 1 addition & 1 deletion src/Strategy/CopyContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct($path = null)
$this->walk = (bool)$path;
}

public function __invoke($data, $context = null)
public function __invoke($record, $context = null)
{
if ($this->walk) {
return parent::__invoke($context);
Expand Down
2 changes: 1 addition & 1 deletion src/Strategy/CopyKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CopyKey implements Strategy, KeyAware
{
use KeyAwareTrait;

public function __invoke($data, $context = null)
public function __invoke($record, $context = null)
{
return $this->key;
}
Expand Down
37 changes: 0 additions & 37 deletions src/Strategy/Translate.php

This file was deleted.

14 changes: 0 additions & 14 deletions test/Functional/DocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,20 +312,6 @@ public function testToList()
);
}

public function testTranslate()
{
self::assertSame(
'bar',
(new Mapper)->map(
['foo' => 'foo'],
new Translate(
new Copy('foo'),
['foo' => 'bar']
)
)
);
}

public function testTryCatch()
{
self::assertSame(
Expand Down
26 changes: 0 additions & 26 deletions test/Integration/Mapper/Strategy/TranslateTest.php

This file was deleted.

0 comments on commit fb31788

Please sign in to comment.