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 DataValues\DataValue; |
||
6 | use Deserializers\Deserializer; |
||
7 | use Mediawiki\Api\MediawikiApi; |
||
8 | use Mediawiki\Api\SimpleRequest; |
||
9 | use Wikibase\Api\GenericOptions; |
||
10 | |||
11 | /** |
||
12 | * @access private |
||
13 | * |
||
14 | * @author Adam Shorland |
||
15 | */ |
||
16 | class ValueFormatter { |
||
17 | |||
18 | /** |
||
19 | * @var MediawikiApi |
||
20 | */ |
||
21 | private $api; |
||
22 | |||
23 | /** |
||
24 | * @var Deserializer |
||
25 | */ |
||
26 | private $dataValueSerializer; |
||
27 | |||
28 | /** |
||
29 | * @param MediawikiApi $api |
||
30 | * @param Deserializer $dataValueSerializer |
||
31 | */ |
||
32 | public function __construct( MediawikiApi $api, Deserializer $dataValueSerializer ) { |
||
33 | $this->api = $api; |
||
34 | $this->dataValueSerializer = $dataValueSerializer; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @since 0.2 |
||
39 | * |
||
40 | * @param DataValue $value |
||
41 | * @param string $dataTypeId |
||
42 | * @param GenericOptions $options |
||
43 | * |
||
44 | * @returns string |
||
45 | */ |
||
46 | public function format( DataValue $value, $dataTypeId, GenericOptions $options = null ) { |
||
47 | if( $options === null ) { |
||
48 | $options = new GenericOptions(); |
||
49 | } |
||
50 | |||
51 | $params = array( |
||
52 | 'datavalue' => json_encode( $this->dataValueSerializer->serialize( $value ) ), |
||
0 ignored issues
–
show
|
|||
53 | 'datatype' => $dataTypeId, |
||
54 | 'options' => json_encode( $options->getOptions() ), |
||
55 | ); |
||
56 | |||
57 | $result = $this->api->getRequest( new SimpleRequest( 'wbformatvalue', $params ) ); |
||
58 | return $result['result']; |
||
59 | } |
||
60 | |||
61 | } |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.