| Total Complexity | 5 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | public function withName(string $name): self |
||
| 27 | { |
||
| 28 | $this->name = $name; |
||
| 29 | |||
| 30 | return $this; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function withFields(?array $fields): self |
||
| 34 | { |
||
| 35 | $this->fields = $fields; |
||
| 36 | |||
| 37 | return $this; |
||
| 38 | } |
||
| 39 | |||
| 40 | public function withRepository(object $repository): self |
||
| 41 | { |
||
| 42 | $this->repository = $repository; |
||
| 43 | |||
| 44 | return $this; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function withUpdateMethod(?string $updateMethod): self |
||
| 48 | { |
||
| 49 | $this->updateMethod = $updateMethod; |
||
| 50 | |||
| 51 | return $this; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function withCommitMethod(?string $commitMethod): self |
||
| 59 | } |
||
| 60 | } |
||
| 61 |