These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Wikibase\Api\Service; |
||
4 | |||
5 | use Mediawiki\DataModel\EditInfo; |
||
6 | use UnexpectedValueException; |
||
7 | use Wikibase\Api\WikibaseApi; |
||
8 | use Wikibase\DataModel\Statement\Statement; |
||
9 | use Wikibase\DataModel\Statement\StatementGuid; |
||
10 | |||
11 | /** |
||
12 | * @access private |
||
13 | * |
||
14 | * @author Addshore |
||
15 | */ |
||
16 | class StatementRemover { |
||
17 | |||
18 | /** |
||
19 | * @var WikibaseApi |
||
20 | */ |
||
21 | private $api; |
||
22 | |||
23 | /** |
||
24 | * @param WikibaseApi $api |
||
25 | */ |
||
26 | public function __construct( WikibaseApi $api ) { |
||
27 | $this->api = $api; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @since 0.2 |
||
32 | * |
||
33 | * @param Statement|StatementGuid|string $statement Statement object or GUID |
||
34 | * @param EditInfo|null $editInfo |
||
35 | * |
||
36 | * @return bool |
||
37 | * @throws UnexpectedValueException |
||
38 | */ |
||
39 | public function remove( $statement, EditInfo $editInfo = null ) { |
||
40 | if( is_string( $statement ) ) { |
||
41 | $guid = $statement; |
||
42 | } else if ( $statement instanceof StatementGuid ) { |
||
43 | $guid = $statement->getSerialization(); |
||
0 ignored issues
–
show
|
|||
44 | } else if ( $statement instanceof Statement ) { |
||
45 | $guid = $statement->getGuid(); |
||
46 | } else { |
||
47 | throw new UnexpectedValueException( 'Could not get statement guid from $statement' ); |
||
48 | } |
||
49 | if( !is_string( $guid ) ) { |
||
50 | throw new UnexpectedValueException( 'Unexpected statement guid got from $statement' ); |
||
51 | } |
||
52 | |||
53 | $params = array( |
||
54 | 'claim' => $guid, |
||
55 | ); |
||
56 | |||
57 | $this->api->postRequest( 'wbremoveclaims', $params, $editInfo ); |
||
58 | return true; |
||
59 | } |
||
60 | |||
61 | } |
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.