| Total Complexity | 7 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class CollisionHandler implements CollisionHandlerInterface |
||
| 9 | { |
||
| 10 | public function __construct(Path $pathUtil = null) |
||
| 13 | } |
||
| 14 | |||
| 15 | /** |
||
| 16 | * {@inheritdoc} |
||
| 17 | */ |
||
| 18 | public function handle(string $targetFile, string $newContent, array $parameters = null) |
||
| 19 | { |
||
| 20 | switch ($this->pathUtil->getExtension($targetFile)) { |
||
| 21 | case 'json': |
||
| 22 | $this->mergeJson($targetFile, $newContent); |
||
| 23 | break; |
||
| 24 | |||
| 25 | case 'md': |
||
| 26 | $this->appendFile($targetFile, "\n---\n" . $newContent); |
||
| 27 | break; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | protected function mergeJson(string $targetFile, string $newContent) |
||
| 38 | } |
||
| 39 | |||
| 40 | protected function appendFile(string $targetFile, string $newContent) |
||
| 45 |