Skip to content

Commit 0e835cc

Browse files
authored
Removed DateEntry and fixed DateTimeEntry::value (#64)
* Removed DateEntry and fixed DateTimeEntry::value * Fixed failing tests
1 parent 4a9a6a3 commit 0e835cc

19 files changed

+116
-224
lines changed

‎README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ This is a perfect scenario for ETL.
3737
* [ArrayEntry](src/Flow/ETL/Row/Entry/ArrayEntry.php)
3838
* [BooleanEntry](src/Flow/ETL/Row/Entry/BooleanEntry.php)
3939
* [FloatEntry](src/Flow/ETL/Row/Entry/FloatEntry.php)
40-
* [DateEntry](src/Flow/ETL/Row/Entry/DateEntry.php)
4140
* [DateTimeEntry](src/Flow/ETL/Row/Entry/DateTimeEntry.php)
4241
* [IntegerEntry](src/Flow/ETL/Row/Entry/IntegerEntry.php)
4342
* [NullEntry](src/Flow/ETL/Row/Entry/NullEntry.php)

‎src/Flow/ETL/Row.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Flow\ETL;
66

77
use Flow\ETL\Exception\RuntimeException;
8-
use Flow\ETL\Row\Converter;
98
use Flow\ETL\Row\Entries;
109
use Flow\ETL\Row\Entry;
1110

@@ -83,13 +82,6 @@ public function rename(string $currentName, string $newName) : self
8382
);
8483
}
8584

86-
public function convert(string $name, Converter $converter) : self
87-
{
88-
return $this->set(
89-
$converter->convert($this->get($name))
90-
);
91-
}
92-
9385
/**
9486
* @param callable(Entry) : bool $callable
9587
*/

‎src/Flow/ETL/Row/Entry/ArrayEntry.php‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ final class ArrayEntry implements Entry
1818
private string $name;
1919

2020
/**
21-
* @phpstan-ignore-next-line
21+
* @var array<mixed>
2222
*/
2323
private array $value;
2424

2525
/**
26-
* @phpstan-ignore-next-line
26+
* @param string $name
27+
* @param array<mixed> $value
28+
*
29+
* @throws InvalidArgumentException
2730
*/
2831
public function __construct(string $name, array $value)
2932
{
@@ -42,8 +45,7 @@ public function name() : string
4245
}
4346

4447
/**
45-
* @psalm-suppress MissingReturnType
46-
* @phpstan-ignore-next-line
48+
* @return array<mixed>
4749
*/
4850
public function value() : array
4951
{
@@ -55,13 +57,18 @@ public function is(string $name) : bool
5557
return $this->key === \mb_strtolower($name);
5658
}
5759

60+
/**
61+
* @throws InvalidArgumentException
62+
*/
5863
public function rename(string $name) : Entry
5964
{
6065
return new self($name, $this->value);
6166
}
6267

6368
/**
6469
* @psalm-suppress MixedArgument
70+
*
71+
* @throws InvalidArgumentException
6572
*/
6673
public function map(callable $mapper) : Entry
6774
{

‎src/Flow/ETL/Row/Entry/BooleanEntry.php‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ public function name() : string
6060
return $this->name;
6161
}
6262

63-
/**
64-
* @psalm-suppress MissingReturnType
65-
*/
6663
public function value() : bool
6764
{
6865
return $this->value;
@@ -73,13 +70,18 @@ public function is(string $name) : bool
7370
return $this->key === \mb_strtolower($name);
7471
}
7572

73+
/**
74+
* @throws InvalidArgumentException
75+
*/
7676
public function rename(string $name) : Entry
7777
{
7878
return new self($name, $this->value);
7979
}
8080

8181
/**
8282
* @psalm-suppress MixedArgument
83+
*
84+
* @throws InvalidArgumentException
8385
*/
8486
public function map(callable $mapper) : Entry
8587
{

‎src/Flow/ETL/Row/Entry/CollectionEntry.php‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ final class CollectionEntry implements Entry
2323
*/
2424
private array $entries;
2525

26+
/**
27+
* @throws InvalidArgumentException
28+
*/
2629
public function __construct(string $name, Entries ...$entries)
2730
{
2831
if (!\strlen($name)) {
@@ -40,8 +43,7 @@ public function name() : string
4043
}
4144

4245
/**
43-
* @psalm-suppress MissingReturnType
44-
* @phpstan-ignore-next-line
46+
* @return array<mixed>
4547
*/
4648
public function value() : array
4749
{
@@ -56,13 +58,18 @@ public function is(string $name) : bool
5658
return $this->key === \mb_strtolower($name);
5759
}
5860

61+
/**
62+
* @throws InvalidArgumentException
63+
*/
5964
public function rename(string $name) : Entry
6065
{
6166
return new self($name, ...$this->entries);
6267
}
6368

6469
/**
6570
* @psalm-suppress MixedArgument
71+
*
72+
* @throws InvalidArgumentException
6673
*/
6774
public function map(callable $mapper) : Entry
6875
{

‎src/Flow/ETL/Row/Entry/DateEntry.php‎

Lines changed: 0 additions & 68 deletions
This file was deleted.

‎src/Flow/ETL/Row/Entry/DateTimeEntry.php‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ final class DateTimeEntry implements Entry
1818

1919
private \DateTimeInterface $value;
2020

21-
private string $format;
22-
23-
public function __construct(string $name, \DateTimeInterface $value, string $format = \DateTimeInterface::ATOM)
21+
/**
22+
* @throws InvalidArgumentException
23+
*/
24+
public function __construct(string $name, \DateTimeInterface $value)
2425
{
2526
if (!\strlen($name)) {
2627
throw InvalidArgumentException::because('Entry name cannot be empty');
@@ -29,21 +30,16 @@ public function __construct(string $name, \DateTimeInterface $value, string $for
2930
$this->key = \mb_strtolower($name);
3031
$this->name = $name;
3132
$this->value = $value;
32-
$this->format = $format;
3333
}
3434

3535
public function name() : string
3636
{
3737
return $this->name;
3838
}
3939

40-
/**
41-
* @psalm-suppress MissingReturnType
42-
* @psalm-suppress ImpureMethodCall
43-
*/
44-
public function value() : string
40+
public function value() : \DateTimeInterface
4541
{
46-
return $this->value->format($this->format);
42+
return $this->value;
4743
}
4844

4945
public function is(string $name) : bool
@@ -58,10 +54,12 @@ public function rename(string $name) : Entry
5854

5955
/**
6056
* @psalm-suppress MixedArgument
57+
*
58+
* @throws InvalidArgumentException
6159
*/
6260
public function map(callable $mapper) : Entry
6361
{
64-
return new self($this->name, $mapper($this->value), $this->format);
62+
return new self($this->name, $mapper($this->value));
6563
}
6664

6765
public function isEqual(Entry $entry) : bool

‎src/Flow/ETL/Row/Entry/FloatEntry.php‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ final class FloatEntry implements Entry
2020

2121
private int $precision;
2222

23+
/**
24+
* @throws InvalidArgumentException
25+
*/
2326
public function __construct(string $name, float $value, int $precision = 6)
2427
{
2528
if (!\strlen($name)) {
@@ -49,9 +52,6 @@ public function name() : string
4952
return $this->name;
5053
}
5154

52-
/**
53-
* @psalm-suppress MissingReturnType
54-
*/
5555
public function value() : float
5656
{
5757
return $this->value;
@@ -62,13 +62,18 @@ public function is(string $name) : bool
6262
return $this->key === \mb_strtolower($name);
6363
}
6464

65+
/**
66+
* @throws InvalidArgumentException
67+
*/
6568
public function rename(string $name) : Entry
6669
{
6770
return new self($name, $this->value);
6871
}
6972

7073
/**
7174
* @psalm-suppress MixedArgument
75+
*
76+
* @throws InvalidArgumentException
7277
*/
7378
public function map(callable $mapper) : Entry
7479
{

‎src/Flow/ETL/Row/Entry/IntegerEntry.php‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ final class IntegerEntry implements Entry
1818

1919
private int $value;
2020

21+
/**
22+
* @throws InvalidArgumentException
23+
*/
2124
public function __construct(string $name, int $value)
2225
{
2326
if (!\strlen($name)) {
@@ -46,9 +49,6 @@ public function name() : string
4649
return $this->name;
4750
}
4851

49-
/**
50-
* @psalm-suppress MissingReturnType
51-
*/
5252
public function value() : int
5353
{
5454
return $this->value;
@@ -59,13 +59,18 @@ public function is(string $name) : bool
5959
return $this->key === \mb_strtolower($name);
6060
}
6161

62+
/**
63+
* @throws InvalidArgumentException
64+
*/
6265
public function rename(string $name) : Entry
6366
{
6467
return new self($name, $this->value);
6568
}
6669

6770
/**
6871
* @psalm-suppress MixedArgument
72+
*
73+
* @throws InvalidArgumentException
6974
*/
7075
public function map(callable $mapper) : Entry
7176
{

‎src/Flow/ETL/Row/Entry/NullEntry.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ final class NullEntry implements Entry
1616

1717
private string $name;
1818

19+
/**
20+
* @throws InvalidArgumentException
21+
*/
1922
public function __construct(string $name)
2023
{
2124
if (!\strlen($name)) {
@@ -41,13 +44,18 @@ public function is(string $name) : bool
4144
return $this->key === \mb_strtolower($name);
4245
}
4346

47+
/**
48+
* @throws InvalidArgumentException
49+
*/
4450
public function rename(string $name) : Entry
4551
{
4652
return new self($name);
4753
}
4854

4955
/**
5056
* @psalm-suppress MixedArgument
57+
*
58+
* @throws InvalidArgumentException
5159
*/
5260
public function map(callable $mapper) : Entry
5361
{

0 commit comments

Comments
 (0)