Code Duplication    Length = 15-17 lines in 2 locations

includes/jobqueue/JobQueueGroup.php 2 locations

@@ 338-354 (lines=17) @@
335
	 *
336
	 * @return array List of job types that have non-empty queues
337
	 */
338
	public function getQueuesWithJobs() {
339
		$types = [];
340
		foreach ( $this->getCoalescedQueues() as $info ) {
341
			$nonEmpty = $info['queue']->getSiblingQueuesWithJobs( $this->getQueueTypes() );
342
			if ( is_array( $nonEmpty ) ) { // batching features supported
343
				$types = array_merge( $types, $nonEmpty );
344
			} else { // we have to go through the queues in the bucket one-by-one
345
				foreach ( $info['types'] as $type ) {
346
					if ( !$this->get( $type )->isEmpty() ) {
347
						$types[] = $type;
348
					}
349
				}
350
			}
351
		}
352
353
		return $types;
354
	}
355
356
	/**
357
	 * Get the size of the queus for a list of job types
@@ 361-375 (lines=15) @@
358
	 *
359
	 * @return array Map of (job type => size)
360
	 */
361
	public function getQueueSizes() {
362
		$sizeMap = [];
363
		foreach ( $this->getCoalescedQueues() as $info ) {
364
			$sizes = $info['queue']->getSiblingQueueSizes( $this->getQueueTypes() );
365
			if ( is_array( $sizes ) ) { // batching features supported
366
				$sizeMap = $sizeMap + $sizes;
367
			} else { // we have to go through the queues in the bucket one-by-one
368
				foreach ( $info['types'] as $type ) {
369
					$sizeMap[$type] = $this->get( $type )->getSize();
370
				}
371
			}
372
		}
373
374
		return $sizeMap;
375
	}
376
377
	/**
378
	 * @return array