for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Ivory Serializer package.
*
* (c) Eric GELOEN <[email protected]>
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*/
namespace Ivory\Serializer\Visitor;
use Ivory\Serializer\Accessor\AccessorInterface;
use Ivory\Serializer\Context\ContextInterface;
use Ivory\Serializer\Mapping\PropertyMetadataInterface;
/**
* @author GeLo <[email protected]>
abstract class AbstractSerializationVisitor extends AbstractGenericVisitor
{
* @var AccessorInterface
private $accessor;
* @param AccessorInterface $accessor
public function __construct(AccessorInterface $accessor)
$this->accessor = $accessor;
}
* {@inheritdoc}
public function getResult()
return $this->encode($this->result);
* @param mixed $data
* @return mixed
abstract protected function encode($data);
protected function doVisitObjectProperty(
$data,
$name,
PropertyMetadataInterface $property,
ContextInterface $context
) {
if (!$property->isReadable()) {
return false;
$result = $this->navigator->navigate(
$this->accessor->getValue(
$property->hasAccessor() ? $property->getAccessor() : $property->getName()
),
$context,
$property->getType()
);
if ($result === null && $context->isNullIgnored()) {
$this->result[$name] = $result;
return true;
protected function createResult($class)
return [];