| Conditions | 6 |
| Paths | 9 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | protected function validateCastValue($val) |
||
| 8 | { |
||
| 9 | if (is_string($val)) { |
||
| 10 | try { |
||
| 11 | $val = json_decode($val); |
||
| 12 | } catch (\Exception $e) { |
||
| 13 | throw $this->getValidationException($e->getMessage(), $val); |
||
| 14 | } |
||
| 15 | } |
||
| 16 | if (!is_object($val)) { |
||
| 17 | throw $this->getValidationException('must be an object', $val); |
||
| 18 | } |
||
| 19 | if ($this->format() == 'default') { |
||
| 20 | try { |
||
| 21 | // this validates the geojson |
||
| 22 | \GeoJson\GeoJson::jsonUnserialize($val); |
||
| 23 | } catch (\Exception $e) { |
||
| 24 | throw $this->getValidationException($e->getMessage(), $val); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | return $val; |
||
| 29 | } |
||
| 30 | |||
| 36 |