/**
  * @param Message $startMessage
  * @param Workflow $workflow
  * @return StartMessageWasAssignedToWorkflow
  */
 public static function record(Message $startMessage, Workflow $workflow)
 {
     $event = self::occur($workflow->workflowId()->toString(), ['start_message' => ['message_type' => $startMessage->messageType()->toString(), 'processing_type' => $startMessage->processingType()->of(), 'metadata' => $startMessage->processingMetadata()->toArray()]]);
     $event->workflowId = $workflow->workflowId();
     $event->startMessage = $startMessage;
     return $event;
 }
 /**
  * @param Process $process
  * @param Workflow $workflow
  * @return ProcessWasAddedToWorkflow
  */
 public static function record(Process $process, Workflow $workflow)
 {
     $event = self::occur($workflow->workflowId()->toString(), ['process_id' => $process->id()->toString(), 'process_type' => $process->type()->toString(), 'task_list' => array_map(function (TaskId $taskId) {
         $taskId->toString();
     }, $process->tasks())]);
     $event->workflowId = $workflow->workflowId();
     $event->processId = $process->id();
     $event->processType = $process->type();
     $event->tasks = $process->tasks();
     return $event;
 }
 /**
  * @param Task $task
  * @param Workflow $workflow
  * @return TaskProcessNotFound
  */
 public static function of(Task $task, Workflow $workflow)
 {
     return new self(sprintf("Workflow %s (%s) has no process defined which has task %s on its task list", $workflow->name(), $workflow->workflowId()->toString(), $task->id()->toString()));
 }
 /**
  * @param int $desiredReleaseNumber
  * @param Workflow $workflow
  * @return WorkflowReleaseAlreadyExists
  */
 public static function withReleaseNumber($desiredReleaseNumber, Workflow $workflow)
 {
     return new self(sprintf('A workflow release for workflow %s (%s) with the release number %s already exists', $workflow->name(), $workflow->workflowId()->toString(), $desiredReleaseNumber));
 }