renderFunction = $renderFunction; $this->object = $object; try { $this->Persistence_Object_Identifier = ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', true); } catch (PropertyNotAccessibleException $e) { // ok. fine } } public function __toString(): string { $render = $this->renderFunction; return $render($this->object); } }