Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
HookRunner
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 onTemplateStylesPropertySanitizer
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onTemplateStylesStylesheetSanitizer
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Extension\TemplateStyles\Hooks;
4
5use MediaWiki\HookContainer\HookContainer;
6use Wikimedia\CSS\Grammar\MatcherFactory;
7use Wikimedia\CSS\Sanitizer\StylePropertySanitizer;
8use Wikimedia\CSS\Sanitizer\StylesheetSanitizer;
9
10/**
11 * This is a hook runner class, see docs/Hooks.md in core.
12 * @internal
13 */
14class HookRunner implements
15    TemplateStylesPropertySanitizerHook,
16    TemplateStylesStylesheetSanitizerHook
17{
18    private HookContainer $hookContainer;
19
20    public function __construct( HookContainer $hookContainer ) {
21        $this->hookContainer = $hookContainer;
22    }
23
24    /**
25     * @inheritDoc
26     */
27    public function onTemplateStylesPropertySanitizer(
28        StylePropertySanitizer &$propertySanitizer,
29        MatcherFactory $matcherFactory
30    ) {
31        return $this->hookContainer->run(
32            'TemplateStylesPropertySanitizer',
33            [ &$propertySanitizer, $matcherFactory ]
34        );
35    }
36
37    /**
38     * @inheritDoc
39     */
40    public function onTemplateStylesStylesheetSanitizer(
41        StylesheetSanitizer &$sanitizer,
42        StylePropertySanitizer $propertySanitizer,
43        MatcherFactory $matcherFactory
44    ) {
45        return $this->hookContainer->run(
46            'TemplateStylesStylesheetSanitizer',
47            [ &$sanitizer, $propertySanitizer, $matcherFactory ]
48        );
49    }
50}