Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 36 additions & 35 deletions Serializer/JMSHandlerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,40 @@
*/
class JMSHandlerRegistry implements HandlerRegistryInterface
{
private $registry;

public function __construct(HandlerRegistryInterface $registry)
{
$this->registry = $registry;
}

/**
* {@inheritdoc}
*/
public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
{
$this->registry->registerSubscribingHandler($handler);
}

/**
* {@inheritdoc}
*/
public function registerHandler($direction, $typeName, $format, $handler): void
{
$this->registry->registerHandler($direction, $typeName, $format, $handler);
}

/**
* {@inheritdoc}
*/
public function getHandler($direction, $typeName, $format)
{
do {
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
return $handler;
}
} while ($typeName = get_parent_class($typeName));
}
private $registry;

public function __construct(HandlerRegistryInterface $registry)
{
$this->registry = $registry;
}

public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
{
$this->registry->registerSubscribingHandler($handler);
}

/**
* {@inheritdoc}
*/
public function registerHandler($direction, $typeName, $format, $handler): void
{
$this->registry->registerHandler($direction, $typeName, $format, $handler);
}

/**
* {@inheritdoc}
*
* @return callable|object
*/
public function getHandler($direction, $typeName, $format)
{
do {
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
return $handler;
}
} while ($typeName = get_parent_class($typeName));

return null;
}
}
72 changes: 37 additions & 35 deletions Serializer/JMSHandlerRegistryV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,41 @@
*/
final class JMSHandlerRegistryV2 implements HandlerRegistryInterface
{
private $registry;

public function __construct(HandlerRegistryInterface $registry)
{
$this->registry = $registry;
}

/**
* {@inheritdoc}
*/
public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
{
$this->registry->registerSubscribingHandler($handler);
}

/**
* {@inheritdoc}
*/
public function registerHandler(int $direction, string $typeName, string $format, $handler): void
{
$this->registry->registerHandler($direction, $typeName, $format, $handler);
}

/**
* {@inheritdoc}
*/
public function getHandler(int $direction, string $typeName, string $format)
{
do {
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
return $handler;
}
} while ($typeName = get_parent_class($typeName));
}
private $registry;

public function __construct(HandlerRegistryInterface $registry)
{
$this->registry = $registry;
}

public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
{
$this->registry->registerSubscribingHandler($handler);
}

/**
* {@inheritdoc}
*/
public function registerHandler(int $direction, string $typeName, string $format, $handler): void
{
$this->registry->registerHandler($direction, $typeName, $format, $handler);
}


/**
* {@inheritdoc}
*
* @return callable|object
*/
public function getHandler(int $direction, string $typeName, string $format)
{
do {
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
return $handler;
}
} while ($typeName = get_parent_class($typeName));

return null;
}
}