/**
  * @param \DateTime $date
  * @param TimeSpent $timeSpent
  * @return void
  */
 public function addTimeSpent(\DateTime $date, TimeSpent $timeSpent)
 {
     if (!array_key_exists($date->format(self::DATE_FORMAT), $this->timeSpentPerDateList)) {
         $this->timeSpentPerDateList[$date->format(self::DATE_FORMAT)] = 0;
     }
     $this->timeSpentPerDateList[$date->format(self::DATE_FORMAT)] += $timeSpent->getValue();
 }
 public function testFormat()
 {
     $timeSpent = new TimeSpent(9900);
     $this->assertEquals('2h 45m', $timeSpent->format());
     $timeSpent = new TimeSpent(178440);
     $this->assertEquals('2d 1h 34m', (string) $timeSpent);
 }
 /**
  * {@inheritdoc}
  */
 public function validate($value, Constraint $constraint)
 {
     /** @var TimeSpent $constraint */
     if (false === TimeSpentObject::isValid($value)) {
         $this->context->addViolation($constraint->message, ['%string%' => $value]);
     }
 }