/**
  * Convert state object to model representation.
  *
  * @param State $state The state being persisted.
  *
  * @return StateModel
  */
 private function convertStateToModel(State $state)
 {
     $model = new StateModel();
     $model->workflowName = $state->getWorkflowName();
     $model->entityId = (string) $state->getEntityId();
     $model->transitionName = $state->getTransitionName();
     $model->stepName = $state->getStepName();
     $model->success = $state->isSuccessful();
     $model->errors = $this->serialize($state->getErrors());
     $model->data = $this->serialize($state->getData());
     $model->reachedAt = $state->getReachedAt()->getTimestamp();
     $model->tstamp = time();
     return $model;
 }