You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
477 B
30 lines
477 B
3 years ago
|
<?php
|
||
|
|
||
|
namespace DbCopy\Transform;
|
||
|
|
||
|
class Group extends Transform
|
||
|
{
|
||
|
private $_transforms;
|
||
|
|
||
|
public function __construct(array $transforms)
|
||
|
{
|
||
|
$this->_transforms = $transforms;
|
||
|
}
|
||
|
|
||
|
public static function create(array $transforms): Group
|
||
|
{
|
||
|
return new Group($transforms);
|
||
|
}
|
||
|
|
||
|
public function __invoke($record): ?array
|
||
|
{
|
||
|
foreach ($this->_transforms as $transform)
|
||
|
{
|
||
|
$record = $transform($record);
|
||
|
if (!isset($record))
|
||
|
return null;
|
||
|
}
|
||
|
return $record;
|
||
|
}
|
||
|
}
|