| @@ -39,9 +39,19 @@ | ||
| 39 | 39 | if( $class instanceof Style ){ |
| 40 | 40 | $class->{$propName} = $jsonValue; |
| 41 | 41 | } |
| 42 | 42 | }; |
| 43 | - $documentObject = isset( $dataObject->document ) ? $dataObject->document : $dataObject; | |
| 43 | + $documentObject = $dataObject->document ?? $dataObject; | |
| 44 | + | |
| 45 | + $baseMapper = function ($class, $jsonValue) { | |
| 46 | + if ( is_array( $jsonValue ) && empty( $jsonValue ) ) { | |
| 47 | + return null; | |
| 48 | + } else { | |
| 49 | + return '\Depicter\Document\Models\Common\Styles\Base'; | |
| 50 | + } | |
| 51 | + }; | |
| 52 | + | |
| 53 | + $mapper->classMap['\Depicter\Document\Models\Common\Styles\Base'] = $baseMapper; | |
| 44 | 54 | $this->document = $mapper->map( $documentObject, new Document() ); |
| 45 | 55 | |
| 46 | 56 | if( $documentId ){ |
| 47 | 57 | $this->document->setDocumentID( $documentId ); |