/** * Constructor * * @param Stream $stream Stream the traveler is on */ public function __construct(Stream $stream) { $this->bag = new Bag(); $this->progress = new TravelerProgress(); $this->progress->stream()->associate($stream); }
/** * Updates the progress to be at the end of the pipe * * @param Traveler $traveler Traveler to store * @param Pipe $pipe Pipe the traveler is going to next * * @return void */ public function endOfPipe(Traveler $traveler, Pipe $pipe) { if ($traveler->nextPipe !== null) { // Create new traveler progress (and thus new traveler) if this // isn't the first pipe to be processed. $progress = new TravelerProgress(); $progress->initialiseProgress(); $progress->stream()->associate($this->stream); $progress->status = 'Traveling'; $progress->pipeable()->associate($pipe->getModel()); $progress->save(); $traveler->progress = $progress; return; } $this->status = 'Traveling'; $this->pipeable()->associate($pipe->getModel()); $this->save(); }