Debian Codegraph @

extensions/Gadgets/includes/StaticGadgetRepo.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Gadgets;
4
5 use InvalidArgumentException;
6
7 /**
8 * @internal For use in tests.
9 */
10 class 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 }