-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- strip the "management" part from the name(space) - move it into the "Converter" namespace - refine class/method names
- Loading branch information
Showing
14 changed files
with
98 additions
and
108 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neusta\ConverterBundle\Converter\Cache; | ||
|
||
/** | ||
* @template TSource of object | ||
* @template TTarget of object | ||
*/ | ||
interface Cache | ||
{ | ||
/** | ||
* @param TSource $source | ||
* | ||
* @return TTarget|null | ||
*/ | ||
public function get(object $source): ?object; | ||
|
||
/** | ||
* @param TSource $source | ||
* @param TTarget $target | ||
*/ | ||
public function set(object $source, object $target): void; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neusta\ConverterBundle\Converter\Cache; | ||
|
||
/** | ||
* @template TSource of object | ||
* @template TTarget of object | ||
* | ||
* @implements Cache<TSource, TTarget> | ||
*/ | ||
final class InMemoryCache implements Cache | ||
{ | ||
/** | ||
* @var array<string, TTarget> | ||
*/ | ||
private array $targets = []; | ||
|
||
/** | ||
* @param CacheKeyFactory<TSource> $keyFactory | ||
*/ | ||
public function __construct( | ||
private CacheKeyFactory $keyFactory, | ||
) { | ||
} | ||
|
||
public function get(object $source): ?object | ||
{ | ||
return $this->targets[$this->keyFactory->createFor($source)] ?? null; | ||
} | ||
|
||
public function set(object $source, object $target): void | ||
{ | ||
$this->targets[$this->keyFactory->createFor($source)] = $target; | ||
} | ||
} |
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
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