| Conditions | 4 |
| Paths | 3 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function serialize( $simpleStatement ) { |
||
| 17 | if ( !( $simpleStatement instanceof SimpleStatement ) ) { |
||
| 18 | throw new UnsupportedObjectException( $simpleStatement, 'Can only serialize instances of SimpleStatement' ); |
||
| 19 | } |
||
| 20 | |||
| 21 | $propertyValue = [ |
||
| 22 | 'value' => $simpleStatement->values[0]->getArrayValue(), |
||
| 23 | 'type' => $simpleStatement->valueType |
||
| 24 | ]; |
||
| 25 | |||
| 26 | if ( count( $simpleStatement->values ) > 1 ) { |
||
| 27 | $propertyValue['values'] = []; |
||
| 28 | |||
| 29 | foreach ( $simpleStatement->values as $value ) { |
||
| 30 | $propertyValue['values'][] = $value->getArrayValue(); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | return $propertyValue; |
||
| 35 | } |
||
| 36 | |||
| 37 | } |