Conditions | 6 |
Paths | 4 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
26 | public function protect( Page $page, $protections, array $extraParams = [] ) { |
||
27 | if ( !is_array( $protections ) || empty( $protections ) ) { |
||
28 | throw new InvalidArgumentException( |
||
29 | '$protections must be an array with keys and values' |
||
30 | ); |
||
31 | } |
||
32 | |||
33 | $params = [ |
||
34 | 'pageid' => $page->getId(), |
||
|
|||
35 | 'token' => $this->api->getToken( 'protect' ), |
||
36 | ]; |
||
37 | $protectionsString = ''; |
||
38 | foreach ( $protections as $action => $value ) { |
||
39 | if ( !is_string( $action ) || !is_string( $value ) ) { |
||
40 | throw new InvalidArgumentException( |
||
41 | 'All keys and elements of $protections must be strings' |
||
42 | ); |
||
43 | } |
||
44 | $protectionsString = $action . '=' . $value . '|'; |
||
45 | } |
||
46 | $params['protections'] = rtrim( $protectionsString, '|' ); |
||
47 | |||
48 | $this->api->postRequest( |
||
49 | new SimpleRequest( 'protect', array_merge( $extraParams, $params ) ) |
||
50 | ); |
||
51 | |||
52 | return true; |
||
53 | } |
||
54 | |||
56 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.