Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
531 B
4
Indexable
Never
public function add(Va $va): Va
  {
    $pattern = "/^(\+62|0|62)(\d*)/i";
    $phone = preg_match($pattern, $va->getPhone(), $arrData);

    try {
      if ($phone == 0) {
        $this->em->persist($va);
        $this->em->flush();
      } else {
        throw new \Exception("Number phone is not valid\n", 400);
      }
    } catch (\Error $e) {
      throw new \Exception("Logger is error", 500);
    } catch (\Exception $e) {
      throw new \Exception("Data is not valid\n" . $e->getMessage(), 400);
    }
    return $va;
  }