Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
3 / 4
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
Math
75.00% covered (warning)
75.00%
3 / 4
75.00% covered (warning)
75.00%
3 / 4
5.39
0.00% covered (danger)
0.00%
0 / 1
 __construct
n/a
0 / 0
n/a
0 / 0
1
 getMathConfig
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCheckerFactory
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getVisitorFactory
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getService
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Extension\Math;
4
5use MediaWiki\Extension\Math\InputCheck\InputCheckFactory;
6use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\VisitorFactory;
7use MediaWiki\MediaWikiServices;
8use Psr\Container\ContainerInterface;
9
10/**
11 * Top level factory for the Math extension.
12 *
13 * @license GPL-2.0-or-later
14 */
15final class Math {
16    /**
17     * @codeCoverageIgnore
18     */
19    private function __construct() {
20        // should not be instantiated
21    }
22
23    public static function getMathConfig( ?ContainerInterface $services = null ): MathConfig {
24        return self::getService( 'Math.Config', $services );
25    }
26
27    public static function getCheckerFactory( ?ContainerInterface $services = null ): InputCheckFactory {
28        return self::getService( 'Math.CheckerFactory', $services );
29    }
30
31    public static function getVisitorFactory( ?ContainerInterface $services = null ): VisitorFactory {
32        return self::getService( 'Math.MathMLTreeVisitor', $services );
33    }
34
35    /**
36     * Retrieves a service instance from the specified or default container.
37     * @param string $serviceName Service identifier to retrieve
38     * @param ContainerInterface|null $services Optional container override for unit tests
39     * @return mixed Service instance
40     */
41    private static function getService( string $serviceName, ?ContainerInterface $services = null ) {
42        return ( $services ?? MediaWikiServices::getInstance() )->getService( $serviceName );
43    }
44}