-
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
109 additions
and
109 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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neusta\ConverterBundle\Converter\Cache; | ||
|
||
/** | ||
* @template TSource of object | ||
* @template TTarget of object | ||
*/ | ||
interface Cache | ||
{ | ||
/** | ||
* @param TSource $source | ||
*/ | ||
public function contains(object $source): bool; | ||
|
||
/** | ||
* @param TSource $source | ||
* | ||
* @return TTarget | ||
*/ | ||
public function fetch(object $source): object; | ||
|
||
/** | ||
* @param TSource $source | ||
* @param TTarget $target | ||
*/ | ||
public function save(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,42 @@ | ||
<?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 contains(object $source): bool | ||
{ | ||
return isset($this->targets[$this->keyFactory->createFor($source)]); | ||
} | ||
|
||
public function fetch(object $source): object | ||
{ | ||
return $this->targets[$this->keyFactory->createFor($source)]; | ||
} | ||
|
||
public function save(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