| Conditions | 5 | 
| Paths | 5 | 
| Total Lines | 24 | 
| Code Lines | 12 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 12 | 
| CRAP Score | 5 | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 33 | 5 | public function toJson(): string  | 
            |
| 34 |     { | 
            ||
| 35 | 5 | $document = [];  | 
            |
| 36 | |||
| 37 | 5 |         foreach ($this->getFields() as $field) { | 
            |
| 38 | 4 | $value = $this->$field;  | 
            |
| 39 | |||
| 40 | 4 |             if (is_null($value)) { | 
            |
| 41 | 1 | continue;  | 
            |
| 42 | }  | 
            ||
| 43 | |||
| 44 | 4 |             if (is_array($value)) { | 
            |
| 45 | 1 |                 foreach (array_keys($value) as $key) { | 
            |
| 46 | 1 |                     $document[sprintf('%1$s.%2$s', $field, $key)] = $value[$key]; | 
            |
| 47 | }  | 
            ||
| 48 | |||
| 49 | 1 | continue;  | 
            |
| 50 | }  | 
            ||
| 51 | |||
| 52 | 4 | $document[$this->toSnakeCase($field)] = $this->$field;  | 
            |
| 53 | }  | 
            ||
| 54 | |||
| 55 | 5 | return json_encode($document);  | 
            |
| 56 | }  | 
            ||
| 57 | |||
| 70 |