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 | */ |
||
17 | 10 | public function __construct(CloneServiceInterface $cloneService, PersistenceServiceInterface $persistenceService) |
|
21 | } |
||
22 | |||
23 | /** |
||
24 | * Clone a model without persisting it |
||
25 | * |
||
26 | * @param $model |
||
27 | * @return Model |
||
28 | */ |
||
29 | 4 | public function clone($model): Model |
|
30 | { |
||
31 | 4 | return $this->cloneService->clone($model); |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * Persist a cloned model |
||
36 | * |
||
37 | * @param $model |
||
38 | * @return Model |
||
39 | */ |
||
40 | 4 | public function persist($model): Model |
|
41 | { |
||
42 | 4 | return $this->persistenceService->persist($model); |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * Clone and persist a model |
||
47 | * |
||
48 | * @param $model |
||
49 | * @return Model |
||
50 | */ |
||
51 | 2 | public function cloneAndPersist($model) : Model |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Retrieve the map of original keys to cloned keys |
||
58 | * |
||
59 | * @return Collection |
||
60 | */ |
||
61 | 2 | public function getKeyMap(): Collection |
|
64 | } |
||
65 | } |
||
66 |