/**
  * {@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);
 }
Beispiel #2
0
 /**
  * TimePenalty constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->startAt = new \DateTime('now');
 }
 public function it_cannot_closes_penalty_twice(Penalty $penalty)
 {
     $penalty->getStatus()->willReturn(Penalty::DONE);
     $this->shouldThrow(PenaltyDoneException::class)->duringClosePenalty($penalty);
 }
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     parent::close();
     $this->setIsPaid(true);
 }