Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
4 / 6
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
Container
66.67% covered (warning)
66.67%
4 / 6
66.67% covered (warning)
66.67%
2 / 3
4.59
0.00% covered (danger)
0.00%
0 / 1
 getContainer
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 reset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Flow;
4
5class Container extends \Pimple\Container {
6    /**
7     * @var self|null
8     */
9    private static $container;
10
11    /**
12     * Get a Flow Container
13     * IMPORTANT: If you are using this function, consider if you can achieve
14     *  your objectives by passing values from an existing, accessible
15     *  container object instead.
16     * If you use this function outside a Flow entry point (such as a hook,
17     *  special page or API module), there is a good chance that your code
18     *  requires refactoring
19     *
20     * @return self
21     */
22    public static function getContainer() {
23        if ( self::$container === null ) {
24            self::$container = include __DIR__ . "/../container.php";
25        }
26        return self::$container;
27    }
28
29    /**
30     * Reset the container, do not use during a normal request.  This is
31     * only for unit tests that need a fresh container.
32     */
33    public static function reset() {
34        self::$container = null;
35    }
36
37    /**
38     * Get a specific item from the Flow Container.
39     * This should only be used from entry points (hooks and such) into flow from mediawiki core.
40     *
41     * @param string $name
42     * @return mixed
43     */
44    public static function get( $name ) {
45        $container = self::getContainer();
46        return $container[$name];
47    }
48}