5
5
6
6
use Doctrine \DBAL \Connection ;
7
7
use Doctrine \DBAL \Schema \Index ;
8
- use SlayerBirden \DataFlow \Handler \Filter ;
9
- use SlayerBirden \DataFlow \Handler \FilterCallbackInterface ;
10
- use SlayerBirden \DataFlow \Handler \Mapper ;
11
- use SlayerBirden \DataFlow \Handler \MapperCallbackInterface ;
8
+ use SlayerBirden \DataFlow \Pipe \Copy ;
9
+ use SlayerBirden \DataFlow \Pipe \Delete ;
10
+ use SlayerBirden \DataFlow \Pipe \Filter ;
11
+ use SlayerBirden \DataFlow \Pipe \FilterCallbackInterface ;
12
+ use SlayerBirden \DataFlow \Pipe \Map ;
13
+ use SlayerBirden \DataFlow \Pipe \MapperCallbackInterface ;
14
+ use SlayerBirden \DataFlow \Pipe \Swap ;
12
15
use SlayerBirden \DataFlow \Writer \ArrayWrite ;
13
16
use SlayerBirden \DataFlow \Writer \Dbal \AutoIncrementCallbackInterface ;
14
17
use SlayerBirden \DataFlow \Writer \Dbal \Write ;
@@ -24,7 +27,7 @@ class PipelineBuilder implements PipelineBuilderInterface
24
27
/**
25
28
* @var WriterUtilityInterface
26
29
*/
27
- private static $ utility ;
30
+ private $ utility ;
28
31
29
32
private $ pipesCount = 0 ;
30
33
/**
@@ -56,17 +59,41 @@ public function map(string $field, MapperCallbackInterface $callback, ?string $i
56
59
if (!$ id ) {
57
60
$ id = 'mapper ' . $ this ->pipesCount ++ . '- ' . $ field ;
58
61
}
59
- return $ this ->addSection (new Mapper ($ id , $ field , $ callback ));
62
+ return $ this ->addSection (new Map ($ id , $ field , $ callback ));
60
63
}
61
64
62
65
public function filter (FilterCallbackInterface $ callback , ?string $ id = null ): PipelineBuilder
63
66
{
64
67
if (!$ id ) {
65
- $ id = 'filter ' . $ this ->pipesCount ++ . '- ' . md5 ( get_class ($ callback) );
68
+ $ id = 'filter ' . $ this ->pipesCount ++ . '- ' . get_class ($ callback );
66
69
}
67
70
return $ this ->addSection (new Filter ($ id , $ callback ));
68
71
}
69
72
73
+ public function delete (array $ names , ?string $ id = null ): PipelineBuilder
74
+ {
75
+ if (!$ id ) {
76
+ $ id = 'delete ' . $ this ->pipesCount ++ . '- ' . json_encode ($ names );
77
+ }
78
+ return $ this ->addSection (new Delete ($ id , ...$ names ));
79
+ }
80
+
81
+ public function swap (string $ first , string $ second , ?string $ id = null ): PipelineBuilder
82
+ {
83
+ if (!$ id ) {
84
+ $ id = 'swap ' . $ this ->pipesCount ++ . '- ' . $ first . '- ' . $ second ;
85
+ }
86
+ return $ this ->addSection (new Swap ($ id , $ first , $ second ));
87
+ }
88
+
89
+ public function cp (string $ from , string $ to , ?string $ id = null ): PipelineBuilder
90
+ {
91
+ if (!$ id ) {
92
+ $ id = 'copy ' . $ this ->pipesCount ++ . '- ' . $ from . '- ' . $ to ;
93
+ }
94
+ return $ this ->addSection (new Copy ($ id , $ from , $ to ));
95
+ }
96
+
70
97
public function dbalWrite (
71
98
string $ table ,
72
99
Connection $ connection ,
@@ -102,10 +129,10 @@ public function getPipeline(): PipeLineInterface
102
129
return $ this ->pipeline ;
103
130
}
104
131
105
- public static function getDbalUtility (Connection $ connection ): WriterUtilityInterface
132
+ public function getDbalUtility (Connection $ connection ): WriterUtilityInterface
106
133
{
107
- if (self :: $ utility === null ) {
108
- self :: $ utility = new class ($ connection ) implements WriterUtilityInterface
134
+ if ($ this -> utility === null ) {
135
+ $ this -> utility = new class ($ connection ) implements WriterUtilityInterface
109
136
{
110
137
/**
111
138
* @var Connection
@@ -139,6 +166,6 @@ public function getUniqueKeys(string $table): array
139
166
}
140
167
};
141
168
}
142
- return self :: $ utility ;
169
+ return $ this -> utility ;
143
170
}
144
171
}
0 commit comments