-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
166 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# TODO | ||
|
||
* Cache should skip unalterable objects | ||
* change unalterabledeterminer to a service | ||
* mechanism to add methods to collector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/TransformerProcessor/PropertyProcessor/CachingPropertyProcessorFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/mapper package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Mapper\TransformerProcessor\PropertyProcessor; | ||
|
||
use Rekalogika\Mapper\Transformer\MainTransformerAwareTrait; | ||
use Rekalogika\Mapper\Transformer\ObjectToObjectMetadata\PropertyMapping; | ||
use Rekalogika\Mapper\TransformerProcessor\PropertyProcessorFactoryInterface; | ||
use Rekalogika\Mapper\TransformerProcessor\PropertyProcessorInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class CachingPropertyProcessorFactory implements PropertyProcessorFactoryInterface | ||
{ | ||
use MainTransformerAwareTrait; | ||
|
||
/** | ||
* @var array<string,PropertyProcessorInterface> $cache | ||
*/ | ||
private array $cache = []; | ||
|
||
public function __construct( | ||
private readonly PropertyProcessorFactoryInterface $decorated, | ||
) {} | ||
|
||
public function getPropertyProcessor( | ||
PropertyMapping $metadata, | ||
): PropertyProcessorInterface { | ||
$id = $metadata->getId(); | ||
|
||
return $this->cache[$id] ??= $this->decorated | ||
->withMainTransformer($this->getMainTransformer()) | ||
->getPropertyProcessor($metadata); | ||
} | ||
} |
Oops, something went wrong.