FIX [duplicate] adding test and handlers to handle fusion of doublons with special cases - after codewithme session

This commit is contained in:
2023-07-13 15:30:33 +02:00
parent 0423540976
commit e0cdf06e99
9 changed files with 377 additions and 32 deletions

View File

@@ -0,0 +1,48 @@
<?php
namespace Chill\PersonBundle\Actions\Remove;
use Chill\PersonBundle\Entity\Person;
class PersonMoveManager
{
public function __construct(
/**
* @var iterable<PersonMoveSqlHandlerInterface>
*/
private iterable $handlers,
)
{
}
/**
* @param class-string $className
* @param string $field
* @return bool
*/
public function hasHandler(string $className, string $field): bool
{
foreach ($this->handlers as $handler) {
if ($handler->supports($className, $field)) {
return true;
}
}
return false;
}
/**
* @param class-string $className
* @return array<string>
*/
public function getSqls(string $className, string $field, Person $from, Person $to): array
{
foreach ($this->handlers as $handler) {
if ($handler->supports($className, $field)) {
return $handler->getSqls($className, $field, $from, $to);
}
}
return [];
}
}