mirror of
https://github.com/Dannecron/coverage-merger.git
synced 2025-12-25 15:52:34 +03:00
create merge clover coverage command
This commit is contained in:
41
src/Clover/Dto/Accumulator.php
Normal file
41
src/Clover/Dto/Accumulator.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dannecron\CoverageMerger\Clover\Dto;
|
||||
|
||||
class Accumulator
|
||||
{
|
||||
/** @var array<string, FileDto> $files */
|
||||
private array $files;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->files = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, FileDto>
|
||||
*/
|
||||
public function getFiles(): array
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
public function addFile(string $fileName, FileDto $file): self
|
||||
{
|
||||
/** @var FileDto|null $existedFile */
|
||||
$existedFile = $this->getFiles()[$fileName] ?? null;
|
||||
|
||||
if ($existedFile !== null) {
|
||||
$existedFile->mergeFile($file);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$merged = \array_merge($this->files, [$fileName => $file]);
|
||||
$this->files = $merged;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user