Skip to content

Commit

Permalink
Extract private .associativeKeys() in KeyTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Nov 24, 2023
1 parent 62a107f commit ddd4b43
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Internal/Frame/KeyTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ private function types(DataFrame $frame): array
{
$types = [];
foreach ($frame->dataset() as $dataRow) {
foreach ($dataRow->keys as $index => $key) {
if ($dataRow->isAssociative($index)) {
$types[$this->typeOf($key)] = true;
}
foreach ($this->associativeKeys($dataRow) as $key) {
$types[$this->typeOf($key)] = true;
}
}
return \array_keys($types);
}

private function associativeKeys(DataRow $row): \Iterator
{
foreach ($row->keys as $index => $key) {
if ($row->isAssociative($index)) {
yield $key;
}
}
}

public function uniformTypes(): bool
{
if ($this->arrayKeyTypes($this->types)) {
Expand Down

0 comments on commit ddd4b43

Please sign in to comment.