-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Join strategy and accompanying tests and documentation.
Removed support for PHP 5.6.
- Loading branch information
Paul
committed
Jan 24, 2017
1 parent
b9c39c9
commit fa9d018
Showing
6 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ sudo: false | |
language: php | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
namespace ScriptFUSION\Mapper\Strategy; | ||
|
||
/** | ||
* Joins sub-string expressions together with a glue string. | ||
*/ | ||
class Join extends Delegate | ||
{ | ||
private $glue; | ||
|
||
/** | ||
* Initializes this instance with the specified glue to join the specified sub-strings together. | ||
* | ||
* @param string $glue Glue. | ||
* @param array ...$expressions Sub-string expressions. | ||
*/ | ||
public function __construct($glue, ...$expressions) | ||
{ | ||
parent::__construct($expressions); | ||
|
||
$this->glue = "$glue"; | ||
} | ||
|
||
public function __invoke($data, $context = null) | ||
{ | ||
return implode($this->glue, parent::__invoke($data, $context)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace ScriptFUSIONTest\Integration\Mapper\Strategy; | ||
|
||
use ScriptFUSION\Mapper\Mapper; | ||
use ScriptFUSION\Mapper\Strategy\Join; | ||
use ScriptFUSION\Mapper\Strategy\Strategy; | ||
|
||
final class JoinTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testJoin() | ||
{ | ||
$join = (new Join( | ||
'-', | ||
'foo', | ||
\Mockery::mock(Strategy::class)->shouldReceive('__invoke')->andReturn('bar')->once()->getMock() | ||
))->setMapper(new Mapper); | ||
|
||
self::assertSame('foo-bar', $join([])); | ||
} | ||
} |