2015-09-18 22:55:40 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Aviat\Ion\Transformer;
|
|
|
|
|
2015-10-09 22:29:59 -04:00
|
|
|
/**
|
|
|
|
* Base class for data trasformation
|
|
|
|
*/
|
2015-09-18 22:55:40 -04:00
|
|
|
abstract class AbstractTransformer implements TransformerInterface {
|
|
|
|
|
2015-10-01 16:02:51 -04:00
|
|
|
use \Aviat\Ion\StringWrapper;
|
|
|
|
|
2015-09-18 22:55:40 -04:00
|
|
|
/**
|
|
|
|
* Mutate the data structure
|
|
|
|
*
|
|
|
|
* @param array|object $item
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
abstract public function transform($item);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform a set of structures
|
|
|
|
*
|
|
|
|
* @param array|object $collection
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform_collection($collection)
|
|
|
|
{
|
2015-10-06 10:24:48 -04:00
|
|
|
$list = (array)$collection;
|
2015-09-18 22:55:40 -04:00
|
|
|
return array_map([$this, 'transform'], $list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// End of AbstractTransformer.php
|