Passed
Push — master ( 3f0976...31b79b )
by Domenico
02:15
created
src/AbstractFilter.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return T The configured instance of the filter.
92 92
      */
93
-    public static function getInstance( FeatureSetInterface $featureSet, ?string $source = null, ?string $target = null, ?array $dataRefMap = [], ?array $handlerTagNamesForLayer0ToLayer1Transition = [] ): ?AbstractFilter {
93
+    public static function getInstance(FeatureSetInterface $featureSet, ?string $source = null, ?string $target = null, ?array $dataRefMap = [], ?array $handlerTagNamesForLayer0ToLayer1Transition = []): ?AbstractFilter {
94 94
         // Create a new instance of the specific filter class (e.g., MateCatFilter).
95 95
         $newInstance = new static();
96 96
 
@@ -101,20 +101,20 @@  discard block
 block discarded – undo
101 101
         // Use the null coalescing operator to default to an empty array if $dataRefMap is null.
102 102
         $newInstance->dataRefMap = $dataRefMap ?? [];
103 103
 
104
-        $handlerClassNamesForLayer0ToLayer1Transition = InjectableFiltersTags::classesForArrayTagNames( $handlerTagNamesForLayer0ToLayer1Transition );
104
+        $handlerClassNamesForLayer0ToLayer1Transition = InjectableFiltersTags::classesForArrayTagNames($handlerTagNamesForLayer0ToLayer1Transition);
105 105
 
106 106
         // Determine which handlers to use for the Layer 0 to Layer 1 transition.
107
-        if ( is_array( $handlerClassNamesForLayer0ToLayer1Transition ) && empty( $handlerClassNamesForLayer0ToLayer1Transition ) ) {
107
+        if (is_array($handlerClassNamesForLayer0ToLayer1Transition) && empty($handlerClassNamesForLayer0ToLayer1Transition)) {
108 108
             // If an empty array is passed, load the default set of handlers from the sorter.
109
-            $handlerClassNamesForLayer0ToLayer1Transition = array_keys( HandlersSorter::getDefaultInjectedHandlers() );
110
-        } elseif ( is_null( $handlerClassNamesForLayer0ToLayer1Transition ) ) {
109
+            $handlerClassNamesForLayer0ToLayer1Transition = array_keys(HandlersSorter::getDefaultInjectedHandlers());
110
+        } elseif (is_null($handlerClassNamesForLayer0ToLayer1Transition)) {
111 111
             // If null is passed, use no handlers.
112 112
             $handlerClassNamesForLayer0ToLayer1Transition = [];
113 113
         }
114 114
         // Otherwise, use the custom list of handlers provided.
115 115
 
116 116
         // Sort the dynamic feature-based handlers.
117
-        $sorter                                                  = new HandlersSorter( $handlerClassNamesForLayer0ToLayer1Transition );
117
+        $sorter                                                  = new HandlersSorter($handlerClassNamesForLayer0ToLayer1Transition);
118 118
         $newInstance->orderedHandlersForLayer0ToLayer1Transition = $sorter->getOrderedHandlersClassNames();
119 119
 
120 120
         // Return the fully configured filter instance.
@@ -132,26 +132,26 @@  discard block
 block discarded – undo
132 132
      * @return string The transformed segment in Layer 0 format.
133 133
      * @throws Exception If any handler in the pipeline fails.
134 134
      */
135
-    public function fromLayer1ToLayer0( string $segment ): string {
135
+    public function fromLayer1ToLayer0(string $segment): string {
136 136
         // Initialize a new pipeline for this transformation.
137
-        $channel = new Pipeline( $this->source, $this->target, $this->dataRefMap );
137
+        $channel = new Pipeline($this->source, $this->target, $this->dataRefMap);
138 138
 
139 139
         // Add handlers to reverse the sub-filtering process.
140
-        $channel->addLast( MateCatCustomPHToOriginalValue::class ); // Restore original PH values
141
-        $channel->addLast( PlaceHoldXliffTags::class );             // Isolate XLIFF tags
142
-        $channel->addLast( EncodeToRawXML::class );                 // Encode for raw XML storage
143
-        $channel->addLast( LtGtEncode::class );                     // Encode '<' and '>'
144
-        $channel->addLast( RestoreXliffTagsContent::class );        // Restore original XLIFF content
145
-        $channel->addLast( RestorePlaceHoldersToXLIFFLtGt::class ); // Restore placeholders for '<' and '>'
146
-        $channel->addLast( SplitPlaceholder::class );               // Handle split placeholders
147
-        $channel->addLast( RestoreEquivText::class );               // Restore equiv-text content
140
+        $channel->addLast(MateCatCustomPHToOriginalValue::class); // Restore original PH values
141
+        $channel->addLast(PlaceHoldXliffTags::class); // Isolate XLIFF tags
142
+        $channel->addLast(EncodeToRawXML::class); // Encode for raw XML storage
143
+        $channel->addLast(LtGtEncode::class); // Encode '<' and '>'
144
+        $channel->addLast(RestoreXliffTagsContent::class); // Restore original XLIFF content
145
+        $channel->addLast(RestorePlaceHoldersToXLIFFLtGt::class); // Restore placeholders for '<' and '>'
146
+        $channel->addLast(SplitPlaceholder::class); // Handle split placeholders
147
+        $channel->addLast(RestoreEquivText::class); // Restore equiv-text content
148 148
 
149 149
         // Allow the current feature set to modify the pipeline (e.g., add or remove handlers).
150 150
         /** @var $channel Pipeline */
151
-        $channel = $this->featureSet->filter( 'fromLayer1ToLayer0', $channel );
151
+        $channel = $this->featureSet->filter('fromLayer1ToLayer0', $channel);
152 152
 
153 153
         // Process the segment through the pipeline and return the result.
154
-        return $channel->transform( $segment );
154
+        return $channel->transform($segment);
155 155
     }
156 156
 
157 157
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      *
168 168
      * @return string The transformed segment after processing from Layer 0 to Layer 1.
169 169
      */
170
-    public abstract function fromLayer0ToLayer1( string $segment, ?string $cid = null ): string;
170
+    public abstract function fromLayer0ToLayer1(string $segment, ?string $cid = null): string;
171 171
 
172 172
     /**
173 173
      * Configures the pipeline for transforming content from Layer 0 to Layer 1.
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
      * @param Pipeline    $channel
183 183
      * @param string|null $cid
184 184
      */
185
-    protected function configureFromLayer0ToLayer1Pipeline( Pipeline $channel, ?string $cid = null ): void {
185
+    protected function configureFromLayer0ToLayer1Pipeline(Pipeline $channel, ?string $cid = null): void {
186 186
 
187 187
         // Add initial handlers for standard XLIFF and placeholder normalization.
188
-        $channel->addLast( StandardPHToMateCatCustomPH::class );
189
-        $channel->addLast( StandardXEquivTextToMateCatCustomPH::class );
190
-        $channel->addLast( PlaceHoldXliffTags::class );
188
+        $channel->addLast(StandardPHToMateCatCustomPH::class);
189
+        $channel->addLast(StandardXEquivTextToMateCatCustomPH::class);
190
+        $channel->addLast(PlaceHoldXliffTags::class);
191 191
 
192 192
         // Add the dynamic feature-based handlers.
193
-        foreach ( $this->orderedHandlersForLayer0ToLayer1Transition as $handler ) {
194
-            $channel->addLast( $handler );
193
+        foreach ($this->orderedHandlersForLayer0ToLayer1Transition as $handler) {
194
+            $channel->addLast($handler);
195 195
         }
196 196
 
197 197
         // Add final handlers to restore XLIFF content and encode for the target layer.
198
-        $channel->addLast( RestoreXliffTagsContent::class );
199
-        $channel->addLast( RestorePlaceHoldersToXLIFFLtGt::class );
200
-        $channel->addLast( EquivTextToBase64::class );
198
+        $channel->addLast(RestoreXliffTagsContent::class);
199
+        $channel->addLast(RestorePlaceHoldersToXLIFFLtGt::class);
200
+        $channel->addLast(EquivTextToBase64::class);
201 201
 
202 202
     }
203 203
 
Please login to merge, or discard this patch.