Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ContractFactory | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| createFromStore | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Service; |
| 6 | |
| 7 | use App\Entity\Contract; |
| 8 | use App\Entity\Store; |
| 9 | |
| 10 | class ContractFactory |
| 11 | { |
| 12 | public function createFromStore(Store $store, ?Contract $template = null): Contract |
| 13 | { |
| 14 | $contract = new Contract(); |
| 15 | |
| 16 | if ($template instanceof Contract) { |
| 17 | $contract->setText($template->getText()); |
| 18 | } |
| 19 | |
| 20 | $contract |
| 21 | ->setStoreNumber((int) $store->getId()) |
| 22 | ->setDestination($store->getDestination()) |
| 23 | ->setValAlq($store->getValAlq()) |
| 24 | ->setCntLanfort($store->getCntLanfort()) |
| 25 | ->setCntLlaves($store->getCntLlaves()) |
| 26 | ->setCntMedAgua($store->getCntMedAgua()) |
| 27 | ->setCntMedElec($store->getCntMedElec()) |
| 28 | ->setCntNeon($store->getCntNeon()) |
| 29 | ->setCntSwitch($store->getCntSwitch()) |
| 30 | ->setCntToma($store->getCntToma()) |
| 31 | ->setCntVentana($store->getCntVentana()) |
| 32 | ->setMedElectrico($store->getMedElectrico()) |
| 33 | ->setMedAgua($store->getMedAgua()); |
| 34 | |
| 35 | return $contract; |
| 36 | } |
| 37 | } |