Code Duplication    Length = 23-23 lines in 4 locations

includes/parser/Preprocessor_DOM.php 2 locations

@@ 1317-1339 (lines=23) @@
1314
	 * @param string|PPNode_DOM|DOMDocument $args,...
1315
	 * @return string
1316
	 */
1317
	public function implodeWithFlags( $sep, $flags /*, ... */ ) {
1318
		$args = array_slice( func_get_args(), 2 );
1319
1320
		$first = true;
1321
		$s = '';
1322
		foreach ( $args as $root ) {
1323
			if ( $root instanceof PPNode_DOM ) {
1324
				$root = $root->node;
1325
			}
1326
			if ( !is_array( $root ) && !( $root instanceof DOMNodeList ) ) {
1327
				$root = [ $root ];
1328
			}
1329
			foreach ( $root as $node ) {
1330
				if ( $first ) {
1331
					$first = false;
1332
				} else {
1333
					$s .= $sep;
1334
				}
1335
				$s .= $this->expand( $node, $flags );
1336
			}
1337
		}
1338
		return $s;
1339
	}
1340
1341
	/**
1342
	 * Implode with no flags specified
@@ 1349-1371 (lines=23) @@
1346
	 * @param string|PPNode_DOM|DOMDocument $args,...
1347
	 * @return string
1348
	 */
1349
	public function implode( $sep /*, ... */ ) {
1350
		$args = array_slice( func_get_args(), 1 );
1351
1352
		$first = true;
1353
		$s = '';
1354
		foreach ( $args as $root ) {
1355
			if ( $root instanceof PPNode_DOM ) {
1356
				$root = $root->node;
1357
			}
1358
			if ( !is_array( $root ) && !( $root instanceof DOMNodeList ) ) {
1359
				$root = [ $root ];
1360
			}
1361
			foreach ( $root as $node ) {
1362
				if ( $first ) {
1363
					$first = false;
1364
				} else {
1365
					$s .= $sep;
1366
				}
1367
				$s .= $this->expand( $node );
1368
			}
1369
		}
1370
		return $s;
1371
	}
1372
1373
	/**
1374
	 * Makes an object that, when expand()ed, will be the same as one obtained

includes/parser/Preprocessor_Hash.php 2 locations

@@ 1139-1161 (lines=23) @@
1136
	 * @param string|PPNode $args,...
1137
	 * @return string
1138
	 */
1139
	public function implodeWithFlags( $sep, $flags /*, ... */ ) {
1140
		$args = array_slice( func_get_args(), 2 );
1141
1142
		$first = true;
1143
		$s = '';
1144
		foreach ( $args as $root ) {
1145
			if ( $root instanceof PPNode_Hash_Array ) {
1146
				$root = $root->value;
1147
			}
1148
			if ( !is_array( $root ) ) {
1149
				$root = [ $root ];
1150
			}
1151
			foreach ( $root as $node ) {
1152
				if ( $first ) {
1153
					$first = false;
1154
				} else {
1155
					$s .= $sep;
1156
				}
1157
				$s .= $this->expand( $node, $flags );
1158
			}
1159
		}
1160
		return $s;
1161
	}
1162
1163
	/**
1164
	 * Implode with no flags specified
@@ 1170-1192 (lines=23) @@
1167
	 * @param string|PPNode $args,...
1168
	 * @return string
1169
	 */
1170
	public function implode( $sep /*, ... */ ) {
1171
		$args = array_slice( func_get_args(), 1 );
1172
1173
		$first = true;
1174
		$s = '';
1175
		foreach ( $args as $root ) {
1176
			if ( $root instanceof PPNode_Hash_Array ) {
1177
				$root = $root->value;
1178
			}
1179
			if ( !is_array( $root ) ) {
1180
				$root = [ $root ];
1181
			}
1182
			foreach ( $root as $node ) {
1183
				if ( $first ) {
1184
					$first = false;
1185
				} else {
1186
					$s .= $sep;
1187
				}
1188
				$s .= $this->expand( $node );
1189
			}
1190
		}
1191
		return $s;
1192
	}
1193
1194
	/**
1195
	 * Makes an object that, when expand()ed, will be the same as one obtained