constraints = $constraints; } /** * @param TimesheetEntity $timesheet * @param Constraint $constraint */ public function validate($timesheet, Constraint $constraint) { if (!($constraint instanceof TimesheetConstraint)) { throw new UnexpectedTypeException($constraint, Timesheet::class); } if (!\is_object($timesheet) || !($timesheet instanceof TimesheetEntity)) { throw new UnexpectedTypeException($timesheet, TimesheetEntity::class); } foreach ($this->constraints as $constraint) { $this->context ->getValidator() ->inContext($this->context) ->validate($timesheet, $constraint, [Constraint::DEFAULT_GROUP]); } } }