/**
  * {@inheritdoc}
  */
 public function closePenalty(Penalty $penalty)
 {
     if ($penalty->getStatus() === Penalty::DONE) {
         throw new PenaltyDoneException();
     }
     $penalty->close();
     $this->manager->persist($penalty);
     $this->manager->flush();
     $event = new PenaltyEvent($penalty);
     $this->dispatcher->dispatch(PenaltyEvents::PENALTY_CLOSED, $event);
 }
 public function it_cannot_closes_penalty_twice(Penalty $penalty)
 {
     $penalty->getStatus()->willReturn(Penalty::DONE);
     $this->shouldThrow(PenaltyDoneException::class)->duringClosePenalty($penalty);
 }