From 66dba8936d370b29dd1df6845ce9d315fe460387 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..351fa40 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(private int $value) { } diff --git a/src/Result/Metric/Table.php b/src/Result/Metric/Table.php new file mode 100644 index 0000000..69566c9 --- /dev/null +++ b/src/Result/Metric/Table.php @@ -0,0 +1,26 @@ + $columns + * @param list> $rows + */ + public function __construct( + private array $columns, + private 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(), + ); + } +}