コード例 #1
0
 /**
  * @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();
 }
コード例 #2
0
 /**
  * @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);
     }
 }