Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
50.00% covered (danger)
50.00%
6 / 12
40.00% covered (danger)
40.00%
4 / 10
CRAP
0.00% covered (danger)
0.00%
0 / 1
StaticStore
50.00% covered (danger)
50.00%
6 / 12
40.00% covered (danger)
40.00%
4 / 10
26.12
0.00% covered (danger)
0.00%
0 / 1
 __construct
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
 getVersion
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 loadConfigurationUncached
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 loadConfiguration
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 alwaysStoreConfiguration
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 storeConfiguration
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 invalidate
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getInfoPageLinkTarget
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 probablyCanEdit
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 definitelyCanEdit
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\CommunityConfiguration\Store;
4
5use LogicException;
6use MediaWiki\Linker\LinkTarget;
7use MediaWiki\Permissions\Authority;
8use StatusValue;
9use stdClass;
10
11class StaticStore extends AbstractStore {
12
13    private stdClass $config;
14
15    /**
16     * @param stdClass|array $config
17     */
18    public function __construct( $config ) {
19        if ( !is_object( $config ) ) {
20            $config = (object)json_decode( json_encode( $config ) );
21        }
22        $this->config = $config;
23    }
24
25    public function getVersion(): ?string {
26        return null;
27    }
28
29    /**
30     * @inheritDoc
31     */
32    public function loadConfigurationUncached(): StatusValue {
33        return StatusValue::newGood( $this->config );
34    }
35
36    /**
37     * @inheritDoc
38     */
39    public function loadConfiguration(): StatusValue {
40        return $this->loadConfigurationUncached();
41    }
42
43    /**
44     * @inheritDoc
45     * @return never
46     */
47    public function alwaysStoreConfiguration(
48        $config,
49        ?string $version,
50        Authority $authority,
51        string $summary = ''
52    ): StatusValue {
53        throw new LogicException( 'Static store cannot be edited' );
54    }
55
56    /**
57     * @inheritDoc
58     * @return never
59     */
60    public function storeConfiguration(
61        $config,
62        ?string $version,
63        Authority $authority,
64        string $summary = ''
65    ): StatusValue {
66        throw new LogicException( 'Static store cannot be edited' );
67    }
68
69    /**
70     * @inheritDoc
71     */
72    public function invalidate(): void {
73    }
74
75    /**
76     * @inheritDoc
77     */
78    public function getInfoPageLinkTarget(): ?LinkTarget {
79        return null;
80    }
81
82    /**
83     * @inheritDoc
84     */
85    public function probablyCanEdit( Authority $authority ): bool {
86        return false;
87    }
88
89    /**
90     * @inheritDoc
91     */
92    public function definitelyCanEdit( Authority $authority ): bool {
93        return false;
94    }
95}