| Total Complexity | 5 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class AbstractModelUpdaterBuilder |
||
| 6 | { |
||
| 7 | protected string $name; |
||
| 8 | |||
| 9 | protected ?array $fields = []; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Instance of model repository |
||
| 13 | */ |
||
| 14 | protected object $repository; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Optional method for updating the model in the repository |
||
| 18 | */ |
||
| 19 | protected ?string $updateMethod = null; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Optional method for committing repository changes to database |
||
| 23 | */ |
||
| 24 | protected ?string $commitMethod = null; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @return $this |
||
| 28 | */ |
||
| 29 | public function withName(string $name): AbstractModelUpdaterBuilder |
||
| 30 | { |
||
| 31 | $this->name = $name; |
||
| 32 | |||
| 33 | return $this; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return $this |
||
| 38 | */ |
||
| 39 | public function withFields(?array $fields): AbstractModelUpdaterBuilder |
||
| 40 | { |
||
| 41 | $this->fields = $fields; |
||
| 42 | |||
| 43 | return $this; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return $this |
||
| 48 | */ |
||
| 49 | public function withRepository(object $repository): AbstractModelUpdaterBuilder |
||
| 50 | { |
||
| 51 | $this->repository = $repository; |
||
| 52 | |||
| 53 | return $this; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return $this |
||
| 58 | */ |
||
| 59 | public function withUpdateMethod(?string $updateMethod): AbstractModelUpdaterBuilder |
||
| 60 | { |
||
| 61 | $this->updateMethod = $updateMethod; |
||
| 62 | |||
| 63 | return $this; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @return $this |
||
| 68 | */ |
||
| 69 | public function withCommitMethod(?string $commitMethod): AbstractModelUpdaterBuilder |
||
| 74 | } |
||
| 75 | } |
||
| 76 |