undefinedPropertyHandler = function( $class, $propName, $jsonValue ){ if( $class instanceof Style ){ $class->{$propName} = $jsonValue; } if ( $class instanceof InnerStyles ) { $innerMapper = new \JsonMapper(); $jsonObject = Data::cast( $jsonValue, 'object'); $class->{$propName} = $innerMapper->map( $jsonObject, new Styles() ); } }; $documentObject = $dataObject->document ?? $dataObject; $baseMapper = function ($class, $jsonValue) { if ( is_array( $jsonValue ) && empty( $jsonValue ) ) { return null; } else { return '\Depicter\Document\Models\Common\Styles\Base'; } }; $mapper->classMap['\Depicter\Document\Models\Common\Styles\Base'] = $baseMapper; $this->document = $mapper->map( $documentObject, new Document() ); if( $documentId ){ $this->document->setDocumentID( $documentId ); } return $this; } /** * Retrieves the mapped Document object * * @return Document */ public function get() { return $this->document; } /** * @return string */ public function render() { return $this->get()->render(); } }