/** * Creates a new {@link LightInstruction}, verifying the action is valid and exactly two * coordinates have been given. * * @param int $action {@link LightInstructionAction} * @param Coordinate[] $coordinatePair two coordinates * @return LightInstruction * @throws \InvalidArgumentException */ public static function create($action, array $coordinatePair) { v::oneOf(v::equals(LightInstructionAction::TURN_ON), v::equals(LightInstructionAction::TURN_OFF), v::equals(LightInstructionAction::TOGGLE))->check($action); v::length(2, 2)->check($coordinatePair); v::each(v::instance('\\Hamdrew\\AdventOfCode\\Day6\\Coordinate'))->check($coordinatePair); return new LightInstruction($action, $coordinatePair); }