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