/**
  * @param PhoneNumber $number
  * @return void
  */
 public function removeNumber(PhoneNumber $number)
 {
     if (!$this->repository->findById($number->getId())) {
         throw new NotExistingPhoneNumberException(sprintf('Phone number with [id = %d] does not exist', $number->getId()));
     }
     $this->repository->remove($number);
     $this->repository->synchronize();
 }
 /**
  * @param PhoneNumber $phoneNumber
  * @throws NotExistingPhoneNumberException
  * @throws EditPhoneNumberException
  */
 private function validatePhoneNumber(PhoneNumber $phoneNumber)
 {
     if (!$this->repository->findById($phoneNumber->getId())) {
         throw new NotExistingPhoneNumberException(sprintf('Phone number with [id = %d] does not exist.', $phoneNumber->getId()));
     }
     $violations = $this->validator->validate($phoneNumber);
     if ($violations->count()) {
         throw new EditPhoneNumberException($violations);
     }
 }
 /**
  * @param PhoneNumber $number
  * @param User $user
  * @param Request $request
  * @return View
  */
 private function processForm(PhoneNumber $number, User $user, Request $request)
 {
     $number->setOwner($user);
     $form = $this->formFactory->createNamed('phoneNumber', 'phone_number_add', $number);
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return new View($form, 400);
     }
     $this->useCase->addNumberToUser($number, $user, false);
     return new View($number, 201, ['Location' => $this->router->generate('arkon_phonebook_get_user_number', ['id' => $user->getId(), 'numberId' => $number->getId()], true)]);
 }