Skip to content

Commit

Permalink
Turned EntryReference into Reference and removed redundant interface
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Sep 17, 2024
1 parent 5951aae commit 654b75a
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Flow\ETL\Adapter\ChartJS;

use Flow\ETL\Row\EntryReference;
use Flow\ETL\Row\Reference;
use Flow\ETL\Rows;

interface Chart
Expand All @@ -13,7 +13,7 @@ public function collect(Rows $rows) : void;

public function data() : array;

public function setDatasetOptions(EntryReference $dataset, array $options) : self;
public function setDatasetOptions(Reference $dataset, array $options) : self;

public function setOptions(array $options) : self;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

use Flow\ETL\Adapter\ChartJS\Chart\{BarChart, LineChart, PieChart};
use Flow\ETL\Attribute\{DocumentationDSL, Module, Type};
use Flow\ETL\Row\{EntryReference, References};
use Flow\ETL\Row\{Reference, References};
use Flow\Filesystem\Path;

#[DocumentationDSL(module: Module::CHART_JS, type: Type::HELPER)]
function bar_chart(EntryReference $label, References $datasets) : BarChart
function bar_chart(Reference $label, References $datasets) : BarChart
{
return new BarChart($label, $datasets);
}

#[DocumentationDSL(module: Module::CHART_JS, type: Type::HELPER)]
function line_chart(EntryReference $label, References $datasets) : LineChart
function line_chart(Reference $label, References $datasets) : LineChart
{
return new LineChart($label, $datasets);
}

#[DocumentationDSL(module: Module::CHART_JS, type: Type::HELPER)]
function pie_chart(EntryReference $label, References $datasets) : PieChart
function pie_chart(Reference $label, References $datasets) : PieChart
{
return new PieChart($label, $datasets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
namespace Flow\ETL\Adapter\Doctrine;

use Doctrine\DBAL\ArrayParameterType;
use Flow\ETL\Row\EntryReference;
use Flow\ETL\Row\Reference;
use Flow\ETL\Rows;

final class Parameter implements QueryParameter
{
public function __construct(
private readonly string $queryParamName,
private readonly EntryReference $ref,
private readonly Reference $ref,
private readonly int|ArrayParameterType $type = ArrayParameterType::STRING,
) {
}

public static function asciis(string $queryParamName, EntryReference $ref) : self
public static function asciis(string $queryParamName, Reference $ref) : self
{
return new self($queryParamName, $ref, ArrayParameterType::ASCII);
}

public static function ints(string $queryParamName, EntryReference $ref) : self
public static function ints(string $queryParamName, Reference $ref) : self
{
return new self($queryParamName, $ref, ArrayParameterType::INTEGER);
}

public static function strings(string $queryParamName, EntryReference $ref) : self
public static function strings(string $queryParamName, Reference $ref) : self
{
return new self($queryParamName, $ref, ArrayParameterType::STRING);
}
Expand Down
32 changes: 16 additions & 16 deletions src/core/etl/src/Flow/ETL/DSL/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
use Flow\ETL\Row\Factory\NativeEntryFactory;
use Flow\ETL\Row\Schema\Formatter\ASCIISchemaFormatter;
use Flow\ETL\Row\Schema\{Definition, Matcher\EvolvingSchemaMatcher, Matcher\StrictSchemaMatcher, SchemaFormatter};
use Flow\ETL\Row\{Entry, EntryFactory, EntryReference, Reference, References, Schema};
use Flow\ETL\Row\{Entry, EntryFactory, Reference, References, Schema};
use Flow\ETL\{Attribute\DocumentationDSL,
Attribute\DocumentationExample,
Attribute\Module,
Expand Down Expand Up @@ -647,26 +647,26 @@ function rows_partitioned(array $rows, array|Partitions $partitions) : Rows
* An alias for `ref`.
*/
#[DocumentationDSL(module: Module::CORE, type: DSLType::DATA_FRAME)]
function col(string $entry) : EntryReference
function col(string $entry) : Reference
{
return new EntryReference($entry);
return new Reference($entry);
}

/**
* An alias for `ref`.
*/
#[DocumentationDSL(module: Module::CORE, type: DSLType::SCALAR_FUNCTION)]
#[DocumentationExample(topic: 'data_frame', example: 'create_entries')]
function entry(string $entry) : EntryReference
function entry(string $entry) : Reference
{
return new EntryReference($entry);
return new Reference($entry);
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::SCALAR_FUNCTION)]
#[DocumentationExample(topic: 'data_frame', example: 'create_entries')]
function ref(string $entry) : EntryReference
function ref(string $entry) : Reference
{
return new EntryReference($entry);
return new Reference($entry);
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::SCALAR_FUNCTION)]
Expand Down Expand Up @@ -837,7 +837,7 @@ function cast(mixed $value, ScalarFunction|string|Type $type) : Cast
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function count(EntryReference $function) : Count
function count(Reference $function) : Count
{
return new Count($function);
}
Expand Down Expand Up @@ -1135,19 +1135,19 @@ function dense_rank() : DenseRank
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function average(EntryReference|string $ref) : Average
function average(Reference|string $ref) : Average
{
return new Average(is_string($ref) ? ref($ref) : $ref);
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function collect(EntryReference|string $ref) : Collect
function collect(Reference|string $ref) : Collect
{
return new Collect(is_string($ref) ? ref($ref) : $ref);
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function collect_unique(EntryReference|string $ref) : CollectUnique
function collect_unique(Reference|string $ref) : CollectUnique
{
return new CollectUnique(is_string($ref) ? ref($ref) : $ref);
}
Expand All @@ -1159,31 +1159,31 @@ function window() : Window
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function sum(EntryReference|string $ref) : Sum
function sum(Reference|string $ref) : Sum
{
return new Sum(is_string($ref) ? ref($ref) : $ref);
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function first(EntryReference|string $ref) : First
function first(Reference|string $ref) : First
{
return new First(is_string($ref) ? ref($ref) : $ref);
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function last(EntryReference|string $ref) : Last
function last(Reference|string $ref) : Last
{
return new Last(is_string($ref) ? ref($ref) : $ref);
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function max(EntryReference|string $ref) : Max
function max(Reference|string $ref) : Max
{
return new Max(is_string($ref) ? ref($ref) : $ref);
}

#[DocumentationDSL(module: Module::CORE, type: DSLType::AGGREGATING_FUNCTION)]
function min(EntryReference|string $ref) : Min
function min(Reference|string $ref) : Min
{
return new Min(is_string($ref) ? ref($ref) : $ref);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/etl/src/Flow/ETL/Function/ListSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Flow\ETL\Row;
use Flow\ETL\Row\Entry\ListEntry;
use Flow\ETL\Row\{EntryReference, Reference, References};
use Flow\ETL\Row\{Reference, References};

final class ListSelect implements ScalarFunction
{
Expand All @@ -18,7 +18,7 @@ public function __construct(
Reference|string $ref,
Reference|string ...$refs,
) {
$this->ref = EntryReference::init($ref);
$this->ref = Reference::init($ref);
$this->refs = References::init(...$refs);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/etl/src/Flow/ETL/Function/StructureSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Flow\ETL\Row;
use Flow\ETL\Row\Entry\StructureEntry;
use Flow\ETL\Row\{EntryReference, Reference, References};
use Flow\ETL\Row\{Reference, References};

final class StructureSelect implements ScalarFunction
{
Expand All @@ -18,7 +18,7 @@ public function __construct(
Reference|string $ref,
Reference|string ...$refs,
) {
$this->ref = EntryReference::init($ref);
$this->ref = Reference::init($ref);
$this->refs = References::init(...$refs);
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/etl/src/Flow/ETL/Join/Comparison/Equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Flow\ETL\Join\Comparison;
use Flow\ETL\Row;
use Flow\ETL\Row\{EntryReference, Reference};
use Flow\ETL\Row\{Reference};

final class Equal implements Comparison
{
Expand All @@ -26,14 +26,14 @@ public function compare(Row $left, Row $right) : bool
*/
public function left() : array
{
return [\is_string($this->entryLeft) ? EntryReference::init($this->entryLeft) : $this->entryLeft];
return [\is_string($this->entryLeft) ? Reference::init($this->entryLeft) : $this->entryLeft];
}

/**
* @return array<Reference>
*/
public function right() : array
{
return [\is_string($this->entryRight) ? EntryReference::init($this->entryRight) : $this->entryRight];
return [\is_string($this->entryRight) ? Reference::init($this->entryRight) : $this->entryRight];
}
}
6 changes: 3 additions & 3 deletions src/core/etl/src/Flow/ETL/Join/Comparison/Identical.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Flow\ETL\Join\Comparison;
use Flow\ETL\Row;
use Flow\ETL\Row\{EntryReference, Reference};
use Flow\ETL\Row\{Reference};

final class Identical implements Comparison
{
Expand All @@ -26,14 +26,14 @@ public function compare(Row $left, Row $right) : bool
*/
public function left() : array
{
return [\is_string($this->entryLeft) ? EntryReference::init($this->entryLeft) : $this->entryLeft];
return [\is_string($this->entryLeft) ? Reference::init($this->entryLeft) : $this->entryLeft];
}

/**
* @return array<Reference>
*/
public function right() : array
{
return [\is_string($this->entryRight) ? EntryReference::init($this->entryRight) : $this->entryRight];
return [\is_string($this->entryRight) ? Reference::init($this->entryRight) : $this->entryRight];
}
}
4 changes: 2 additions & 2 deletions src/core/etl/src/Flow/ETL/Row/Entry/EntryRef.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Flow\ETL\Row\Entry;

use Flow\ETL\Row\{EntryReference, Reference};
use Flow\ETL\Row\{Reference};

trait EntryRef
{
Expand All @@ -15,7 +15,7 @@ abstract public function name() : string;
public function ref() : Reference
{
if ($this->ref === null) {
$this->ref = new EntryReference($this->name());
$this->ref = new Reference($this->name());
}

return $this->ref;
Expand Down
94 changes: 0 additions & 94 deletions src/core/etl/src/Flow/ETL/Row/EntryReference.php

This file was deleted.

Loading

0 comments on commit 654b75a

Please sign in to comment.