From 7198f18c7fc2e5373b066ffd3091aa7bd2798ba0 Mon Sep 17 00:00:00 2001 From: Daniel Wilkowski Date: Fri, 24 Nov 2023 11:41:45 +0100 Subject: [PATCH] Refactor ValueType to Typ --- src/Internal/Frame/KeyTypes.php | 8 ++++++-- src/Internal/Frame/{ValueType.php => Type.php} | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) rename src/Internal/Frame/{ValueType.php => Type.php} (93%) diff --git a/src/Internal/Frame/KeyTypes.php b/src/Internal/Frame/KeyTypes.php index 94d1f69..a23640a 100644 --- a/src/Internal/Frame/KeyTypes.php +++ b/src/Internal/Frame/KeyTypes.php @@ -17,8 +17,7 @@ private function types(DataFrame $frame): array foreach ($frame->dataset() as $dataRow) { foreach ($dataRow->keys as $index => $key) { if ($dataRow->isAssociative($index)) { - $valueType = new ValueType($key); - $types[$valueType->type()] = true; + $types[$this->typeOf($key)] = true; } } } @@ -37,4 +36,9 @@ private function arrayKeyTypes(array $types): bool { return $types == ['string', 'int'] || $types == ['int', 'string']; } + + private function typeOf($value): string + { + return new Type($value); + } } diff --git a/src/Internal/Frame/ValueType.php b/src/Internal/Frame/Type.php similarity index 93% rename from src/Internal/Frame/ValueType.php rename to src/Internal/Frame/Type.php index 53e0e5f..85c17e5 100644 --- a/src/Internal/Frame/ValueType.php +++ b/src/Internal/Frame/Type.php @@ -1,7 +1,7 @@ value = $value; } - public function type(): string + public function __toString(): string { if (\is_string($this->value)) { return 'string';