Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
StaticHookRegistry
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getGlobalHooks
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExtensionHooks
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDeprecatedHooks
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\HookContainer;
4
5/**
6 * This is a simple immutable HookRegistry which can be used to set up a local
7 * HookContainer in tests and for similar purposes.
8 */
9class StaticHookRegistry implements HookRegistry {
10    /** @var array */
11    private $globalHooks;
12
13    /** @var array */
14    private $extensionHooks;
15
16    /** @var DeprecatedHooks */
17    private $deprecatedHooks;
18
19    /**
20     * @param array $globalHooks An array of legacy hooks in the same format as $wgHooks
21     * @param array $extensionHooks An array of modern hooks in the format
22     *   described in HookRegistry::getExtensionHooks()
23     * @param array $deprecatedHooksArray An array of deprecated hooks in the
24     *   format expected by DeprecatedHooks::__construct(). These hooks are added
25     *   to the core deprecated hooks list which is always present.
26     */
27    public function __construct(
28        array $globalHooks = [],
29        array $extensionHooks = [],
30        array $deprecatedHooksArray = []
31    ) {
32        $this->globalHooks = $globalHooks;
33        $this->extensionHooks = $extensionHooks;
34        $this->deprecatedHooks = new DeprecatedHooks( $deprecatedHooksArray );
35    }
36
37    public function getGlobalHooks() {
38        return $this->globalHooks;
39    }
40
41    public function getExtensionHooks() {
42        return $this->extensionHooks;
43    }
44
45    /**
46     * @return DeprecatedHooks
47     */
48    public function getDeprecatedHooks() {
49        return $this->deprecatedHooks;
50    }
51}