Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
FundraiserEmailQueue
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 get
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3/**
4 * Helper to fetch and stash a PHPQueue backend
5 * Basically just holds a static reference so tests can look at the same
6 * backend instance as the class being tested
7 */
8class FundraiserEmailQueue {
9    /** @var PHPQueue\Interfaces\FifoQueueStore[] */
10    private static $instances = [];
11
12    /**
13     * @param string $queueName name of the queue to fetch
14     * @return PHPQueue\Interfaces\FifoQueueStore
15     */
16    public static function get( $queueName = 'unsubscribe' ) {
17        global $wgFundraisingEmailUnsubscribeQueueClass,
18               $wgFundraisingEmailUnsubscribeQueueParameters;
19
20        if ( empty( self::$instances[$queueName] ) ) {
21            if ( empty( $wgFundraisingEmailUnsubscribeQueueParameters[$queueName]['queue'] ) ) {
22                $wgFundraisingEmailUnsubscribeQueueParameters[$queueName]['queue'] = $queueName;
23            }
24            self::$instances[$queueName] = new $wgFundraisingEmailUnsubscribeQueueClass(
25                $wgFundraisingEmailUnsubscribeQueueParameters[$queueName]
26            );
27        }
28
29        return self::$instances[$queueName];
30    }
31}