Skip to content

Commit 5efacb5

Browse files
Add Debug loader using symfony/var-dumper, and Sleep Transformer to wait between stages
1 parent b704289 commit 5efacb5

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/Loader/Debug.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Camillebaronnet\ETL\Loader;
4+
5+
use Generator;
6+
7+
class Debug implements LoaderInterface, StreamLoaderInterface
8+
{
9+
public function __invoke(array $data)
10+
{
11+
return dump($data);
12+
}
13+
14+
public function stream(Generator $collection): void
15+
{
16+
foreach ($collection as $row) {
17+
dump($row);
18+
}
19+
}
20+
}

src/Transformer/Sleep.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Camillebaronnet\ETL\Transformer;
4+
5+
class Sleep implements TransformInterface
6+
{
7+
public $seconds = 1;
8+
9+
/**
10+
* The saved context, hydrated by the __invoke.
11+
*
12+
* @var array
13+
*/
14+
protected $context = [];
15+
16+
/**
17+
* The class entry point.
18+
*/
19+
public function __invoke(array $data): array
20+
{
21+
sleep($this->seconds);
22+
23+
return $data;
24+
}
25+
}

0 commit comments

Comments
 (0)