-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQualityReport.php
More file actions
41 lines (36 loc) · 1 KB
/
QualityReport.php
File metadata and controls
41 lines (36 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
namespace KaririCode\Devkit\ValueObject;
/**
* Aggregated result of a full quality pipeline.
*
* @since 1.0.0
*/
final readonly class QualityReport
{
public bool $passed;
public float $totalSeconds;
public int $failureCount;
/** @param list<ToolResult> $results */
public function __construct(
public array $results,
) {
$this->passed = array_all($results, static fn (ToolResult $r): bool => $r->success);
$this->totalSeconds = array_sum(array_map(
static fn (ToolResult $r): float => $r->elapsedSeconds,
$results,
));
$this->failureCount = \count(array_filter(
$results,
static fn (ToolResult $r): bool => ! $r->success,
));
}
/** @return list<ToolResult> */
public function failures(): array
{
return array_values(array_filter(
$this->results,
static fn (ToolResult $r): bool => ! $r->success,
));
}
}