for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace AmaTeam\ElasticSearch\Entity\Mapping\Inheritance;
use AmaTeam\ElasticSearch\API\Entity\Mapping\ClassMapping;
use AmaTeam\ElasticSearch\API\Entity\Mapping\ClassMappingInterface;
use AmaTeam\ElasticSearch\API\Entity\Mapping\ClassMappingView;
use AmaTeam\ElasticSearch\API\Entity\Mapping\PropertyMapping;
class Combiner
{
public static function combine(ClassMappingInterface $parent, ClassMappingInterface $child): ClassMappingInterface
$target = new ClassMapping();
$target->setEntityName($child->getEntityName());
$defaultView = ClassMappingView::merge($parent->getDefaultView(), $child->getDefaultView());
$target->setDefaultView($defaultView);
foreach ($parent->getViews() as $name => $view) {
$target->setView($name, ClassMappingView::merge($target->requestView($name), $view));
}
foreach ($child->getViews() as $name => $view) {
$ignoredProperties = $child->getIgnoredParentProperties() ?? [];
foreach ($parent->getProperties() as $name => $property) {
if (!in_array($name, $ignoredProperties)) {
$target->setProperty($name, $property);
foreach ($child->getProperties() as $name => $property) {
$target->setProperty($name, PropertyMapping::merge($target->requestProperty($name), $property));
return $target;