Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
StaticGadgetRepo
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getGadgetIds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getGadget
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace MediaWiki\Extension\Gadgets;
4
5use InvalidArgumentException;
6
7/**
8 * @internal For use in tests.
9 */
10class StaticGadgetRepo extends GadgetRepo {
11
12    /**
13     * @var Gadget[]
14     */
15    private array $gadgets;
16
17    public function __construct( array $gadgets ) {
18        $this->gadgets = $gadgets;
19    }
20
21    public function getGadgetIds(): array {
22        return array_keys( $this->gadgets );
23    }
24
25    public function getGadget( string $id ): Gadget {
26        if ( !array_key_exists( $id, $this->gadgets ) ) {
27            throw new InvalidArgumentException();
28        }
29        return $this->gadgets[$id];
30    }
31}