From 41761f7b451229fc98a6e8a034cfe1f9ae2384d7 Mon Sep 17 00:00:00 2001 From: Denis Zunke Date: Mon, 15 Apr 2024 19:34:48 +0200 Subject: [PATCH] Implement a table formed result metric --- src/Result/Metric/Integer.php | 4 ++-- src/Result/Metric/Table.php | 26 +++++++++++++++++++++++++ tests/Result/Metric/TableResultTest.php | 24 +++++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/Result/Metric/Table.php create mode 100644 tests/Result/Metric/TableResultTest.php diff --git a/src/Result/Metric/Integer.php b/src/Result/Metric/Integer.php index 3eb509e..338f24b 100644 --- a/src/Result/Metric/Integer.php +++ b/src/Result/Metric/Integer.php @@ -4,9 +4,9 @@ namespace Panaly\Result\Metric; -final class Integer implements Value +final readonly class Integer implements Value { - public function __construct(private readonly int $value) + public function __construct(public int $value) { } diff --git a/src/Result/Metric/Table.php b/src/Result/Metric/Table.php new file mode 100644 index 0000000..a843d5a --- /dev/null +++ b/src/Result/Metric/Table.php @@ -0,0 +1,26 @@ + $columns + * @param list> $rows + */ + public function __construct( + public array $columns, + public array $rows, + ) { + } + + /** @return list> */ + public function compute(): array + { + return array_merge([$this->columns], $this->rows); + } +} diff --git a/tests/Result/Metric/TableResultTest.php b/tests/Result/Metric/TableResultTest.php new file mode 100644 index 0000000..e130ea8 --- /dev/null +++ b/tests/Result/Metric/TableResultTest.php @@ -0,0 +1,24 @@ +compute(), + ); + } +}