| Total Complexity | 5 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class Cloner |
||
| 9 | { |
||
| 10 | private $cloneService; |
||
| 11 | private $persistenceService; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @param CloneServiceInterface $cloneService |
||
| 15 | * @param PersistenceServiceInterface $persistenceService |
||
| 16 | 8 | */ |
|
| 17 | public function __construct(CloneServiceInterface $cloneService, PersistenceServiceInterface $persistenceService) |
||
| 18 | 8 | { |
|
| 19 | 8 | $this->cloneService = $cloneService; |
|
| 20 | 8 | $this->persistenceService = $persistenceService; |
|
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Clone a model without persisting it |
||
| 25 | * |
||
| 26 | * @param $model |
||
| 27 | * @return Model |
||
| 28 | 4 | */ |
|
| 29 | public function clone($model): Model |
||
| 30 | 4 | { |
|
| 31 | return $this->cloneService->clone($model); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Persist a cloned model |
||
| 36 | * |
||
| 37 | * @param $model |
||
| 38 | * @return Model |
||
| 39 | 4 | */ |
|
| 40 | public function persist($model): Model |
||
| 41 | 4 | { |
|
| 42 | return $this->persistenceService->persist($model); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Clone and persist a model |
||
| 47 | * |
||
| 48 | * @param $model |
||
| 49 | * @return Model |
||
| 50 | 2 | */ |
|
| 51 | public function cloneAndPersist($model) : Model |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Retrieve the map of original keys to cloned keys |
||
| 58 | * |
||
| 59 | * @return Collection |
||
| 60 | */ |
||
| 61 | public function getKeyMap(): Collection |
||
| 64 | } |
||
| 65 | } |
||
| 66 |