55namespace Flow \ETL \Config ;
66
77use function Flow \Filesystem \DSL \fstab ;
8+ use Flow \Clock \SystemClock ;
89use Flow \ETL \Config \Cache \CacheConfigBuilder ;
910use Flow \ETL \Config \Sort \SortConfigBuilder ;
1011use Flow \ETL \Filesystem \FilesystemStreams ;
1516use Flow \ETL \{Cache , Config , NativePHPRandomValueGenerator , RandomValueGenerator };
1617use Flow \Filesystem \{Filesystem , FilesystemTable };
1718use Flow \Serializer \{Base64Serializer , NativePHPSerializer , Serializer };
19+ use Psr \Clock \ClockInterface ;
1820
1921final class ConfigBuilder
2022{
@@ -24,6 +26,8 @@ final class ConfigBuilder
2426
2527 private ?Caster $ caster ;
2628
29+ private ?ClockInterface $ clock ;
30+
2731 private ?FilesystemTable $ fstab ;
2832
2933 private ?string $ id ;
@@ -44,6 +48,7 @@ public function __construct()
4448 $ this ->putInputIntoRows = false ;
4549 $ this ->optimizer = null ;
4650 $ this ->caster = null ;
51+ $ this ->clock = null ;
4752 $ this ->cache = new CacheConfigBuilder ();
4853 $ this ->sort = new SortConfigBuilder ();
4954 $ this ->randomValueGenerator = new NativePHPRandomValueGenerator ();
@@ -54,7 +59,7 @@ public function build() : Config
5459 $ this ->id ??= 'flow_php ' . $ this ->randomValueGenerator ->string (32 );
5560 $ entryFactory = new NativeEntryFactory ();
5661 $ this ->serializer ??= new Base64Serializer (new NativePHPSerializer ());
57-
62+ $ this -> clock ??= SystemClock:: utc ();
5863 $ this ->optimizer ??= new Optimizer (
5964 new Optimizer \LimitOptimization (),
6065 new Optimizer \BatchSizeOptimization (batchSize: 1000 )
@@ -65,6 +70,7 @@ public function build() : Config
6570 return new Config (
6671 $ this ->id ,
6772 $ this ->serializer ,
73+ $ this ->clock ,
6874 $ this ->fstab (),
6975 new FilesystemStreams ($ this ->fstab ()),
7076 $ this ->optimizer ,
@@ -83,6 +89,13 @@ public function cache(Cache $cache) : self
8389 return $ this ;
8490 }
8591
92+ public function clock (ClockInterface $ clocks ) : self
93+ {
94+ $ this ->clock = $ clocks ;
95+
96+ return $ this ;
97+ }
98+
8699 public function dontPutInputIntoRows () : self
87100 {
88101 $ this ->putInputIntoRows = false ;
0 commit comments