| Total Complexity | 2 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class PCBuilder implements BuilderInterface |
||
| 15 | { |
||
| 16 | private array $components; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Assembles a computer |
||
| 20 | * -------------------- |
||
| 21 | * Собирает компьютер |
||
| 22 | * |
||
| 23 | * @return ComputerInterface |
||
| 24 | */ |
||
| 25 | public function createComputer(): ComputerInterface |
||
| 26 | { |
||
| 27 | $this |
||
| 28 | ->setPart(new Hardware\Motherboard(Order::MB)) |
||
| 29 | ->setPart(new Hardware\Cpu(Order::CPU)) |
||
| 30 | ->setPart(new Hardware\Ram(Order::RAM)) |
||
| 31 | ->setPart(new Hardware\Gpu(Order::GPU)) |
||
| 32 | ->setPart(new Hardware\Ssd(Order::SSD)) |
||
| 33 | ->setPart(new Hardware\Hdd(Order::HDD)); |
||
| 34 | |||
| 35 | return new Desktop($this->components); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Adds a computer element |
||
| 40 | * ---------------------------- |
||
| 41 | * Добавляет элемент компьютера |
||
| 42 | * |
||
| 43 | * @param AbstractPart $part |
||
| 44 | * @return BuilderInterface |
||
| 45 | */ |
||
| 46 | private function setPart(AbstractPart $part): BuilderInterface |
||
| 50 | } |
||
| 51 | } |
||
| 52 |