checkEmailCode($identity, $code); } elseif (CommonValidator::phone($identity)) { $this->checkSmsCode($identity, $code); } else { throw new BadRequestException('verify.unsupported_identity'); } } public function checkSmsCode($phone, $code) { $service = new VerifyService(); $result = $service->checkSmsCode($phone, $code); if (!$result) { throw new BadRequestException('verify.invalid_sms_code'); } } public function checkEmailCode($email, $code) { $service = new VerifyService(); $result = $service->checkEmailCode($email, $code); if (!$result) { throw new BadRequestException('verify.invalid_email_code'); } } }