Conditions | 5 |
Paths | 6 |
Total Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
25 | public function rotate( File $file, $rotation ) { |
||
26 | $params = [ |
||
27 | 'rotation' => $rotation, |
||
28 | 'token' => $this->api->getToken(), |
||
29 | ]; |
||
30 | |||
31 | if ( $file->getPageIdentifier()->getTitle() !== null ) { |
||
32 | $params['titles'] = $file->getPageIdentifier()->getTitle()->getText(); |
||
33 | } else { |
||
34 | $params['pageids'] = $file->getPageIdentifier()->getId(); |
||
35 | } |
||
36 | |||
37 | $result = $this->api->postRequest( new SimpleRequest( 'imagerotate', $params ) ); |
||
38 | |||
39 | // This module sometimes gives odd errors so deal with them.. |
||
40 | if ( array_key_exists( 'imagerotate', $result ) ) { |
||
41 | $imageRotate = array_pop( $result['imagerotate'] ); |
||
42 | if ( array_key_exists( 'result', $imageRotate ) && |
||
43 | $imageRotate['result'] == 'Failure' |
||
44 | ) { |
||
45 | throw new UsageException( |
||
46 | 'imagerotate-Failure', |
||
47 | $imageRotate['errormessage'], |
||
48 | $result |
||
49 | ); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | return true; |
||
54 | } |
||
55 | |||
57 |