Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | public static function from_json( $method, $json ) { |
||
|
|||
31 | if ( null === $json ) { |
||
32 | return null; |
||
33 | } |
||
34 | |||
35 | $validator = new \JsonSchema\Validator(); |
||
36 | |||
37 | $validator->validate( |
||
38 | $json, |
||
39 | (object) array( |
||
40 | '$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/payment-details.json' ), |
||
41 | ), |
||
42 | \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS |
||
43 | ); |
||
44 | |||
45 | $details = new PaymentDetails(); |
||
46 | |||
47 | foreach ( $json as $key => $value ) { |
||
48 | $details->{$key} = $value; |
||
49 | } |
||
50 | |||
51 | return $details; |
||
52 | } |
||
54 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.