Skip to content

Commit

Permalink
Hide data in ArrayMemory by default
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed Feb 2, 2024
1 parent 824f2da commit eaccced
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/core/etl/src/Flow/ETL/Memory/ArrayMemory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,13 @@
final class ArrayMemory implements \Countable, Memory
{
/**
* @var array<array<string, mixed>>
*/
public array $data;

/**
* @param array<mixed> $memory
* @param array<array-key, array<string, mixed>> $memory
*
* @throws InvalidArgumentException
*/
public function __construct(array $memory = [])
public function __construct(private array $memory = [])
{
$this->assertMemoryStructure($memory);
/** @var array<array-key, array<string, mixed>> $memory */
$this->data = $memory;
}

/**
Expand All @@ -36,7 +29,7 @@ public function chunks(int $size) : array

$chunks = [];

foreach (\array_chunk($this->data, $size) as $chunk) {
foreach (\array_chunk($this->memory, $size) as $chunk) {
$chunks[] = new self($chunk);
}

Expand All @@ -45,7 +38,7 @@ public function chunks(int $size) : array

public function count() : int
{
return \count($this->data);
return \count($this->memory);
}

/**
Expand All @@ -55,7 +48,7 @@ public function count() : int
*/
public function dump() : array
{
return $this->data;
return $this->memory;
}

/**
Expand All @@ -70,7 +63,7 @@ public function flatValues() : array
{
$data = [];

foreach ($this->data as $entry) {
foreach ($this->memory as $entry) {
$data[] = \array_values($entry);
}

Expand All @@ -86,7 +79,7 @@ public function map(callable $callback) : array
{
$data = [];

foreach ($this->data as $entry) {
foreach ($this->memory as $entry) {
$data[] = $callback($entry);
}

Expand All @@ -100,7 +93,7 @@ public function save(array $data) : void
{
$this->assertMemoryStructure($data);

$this->data = \array_merge($this->data, $data);
$this->memory = \array_merge($this->memory, $data);
}

/**
Expand Down

0 comments on commit eaccced

Please sign in to comment.