| Conditions | 3 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 43 | 2 | public static function from_json( $object ) { |
|
| 44 | 2 | $validator = new \JsonSchema\Validator(); |
|
| 45 | |||
| 46 | 2 | $validator->validate( |
|
| 47 | 2 | $object, |
|
| 48 | (object) array( |
||
| 49 | 2 | '$ref' => 'file://' . \realpath( __DIR__ . '/../json-schemas/redirect.json' ), |
|
| 50 | ), |
||
| 51 | 2 | \JsonSchema\Constraints\Constraint::CHECK_MODE_EXCEPTIONS |
|
| 52 | ); |
||
| 53 | |||
| 54 | 2 | $redirect = new self(); |
|
| 55 | |||
| 56 | 2 | if ( \property_exists( $object, 'method' ) ) { |
|
| 57 | 2 | $redirect->method = $object->method; |
|
| 58 | } |
||
| 59 | |||
| 60 | 2 | if ( \property_exists( $object, 'url' ) ) { |
|
| 61 | 2 | $redirect->url = $object->url; |
|
| 62 | } |
||
| 63 | |||
| 64 | 2 | return $redirect; |
|
| 65 | } |
||
| 67 |