changes for filter and print

This commit is contained in:
2024-09-29 16:59:27 +05:45
parent 497f567cba
commit 684e01bf48
1335 changed files with 38709 additions and 74987 deletions

View File

@ -7,6 +7,7 @@ use DateInterval;
use DateTimeInterface;
use DateTimeZone;
use DeepCopy\Exception\CloneException;
use DeepCopy\Filter\ChainableFilter;
use DeepCopy\Filter\Filter;
use DeepCopy\Matcher\Matcher;
use DeepCopy\Reflection\ReflectionHelper;
@ -223,6 +224,11 @@ class DeepCopy
return;
}
// Ignore readonly properties
if (method_exists($property, 'isReadOnly') && $property->isReadOnly()) {
return;
}
// Apply the filters
foreach ($this->filters as $item) {
/** @var Matcher $matcher */
@ -239,6 +245,10 @@ class DeepCopy
}
);
if ($filter instanceof ChainableFilter) {
continue;
}
// If a filter matches, we stop processing this property
return;
}

View File

@ -0,0 +1,24 @@
<?php
namespace DeepCopy\Filter;
/**
* Defines a decorator filter that will not stop the chain of filters.
*/
class ChainableFilter implements Filter
{
/**
* @var Filter
*/
protected $filter;
public function __construct(Filter $filter)
{
$this->filter = $filter;
}
public function apply($object, $property, $objectCopier)
{
$this->filter->apply($object, $property, $objectCopier);
}
}