public function checkPhone() {
    if (empty($this->phone)) {
      return ['result' => false, 'message' => 'Please specify a phone number.'];
    }

    $stripToDigits = preg_replace('/\D/', '', $this->phone);
    if (!preg_match('/\d{10}/', $stripToDigits)) {
      return [
        'result' => false,
        'message' =>
          'Phone must contain 10 digits, but formatting does not matter.'
      ];
    }
    $selector = ['&',
        'strict' => ['phone', $stripToDigits]
      ];
    if (isset($this->guid)) {
      $selector['!guid'] = $this->guid;
    }
    $test = Nymph::getEntity(
        ['class' => '\Tilmeld\Entities\User', 'skip_ac' => true],
        $selector
    );
    if (isset($test->guid)) {
      return ['result' => false, 'message' => 'Phone number is in use.'];
    }

    return [
      'result' => true,
      'message' => (
        isset($this->guid) ? 'Phone number is valid.' : 'Phone number is valid!'
      )
    ];
  }
public function checkPhone() {
    if (empty($this->phone)) {
      return ['result' => false, 'message' => 'Please specify a phone number.'];
    }

    $stripToDigits = preg_replace('/\D/', '', $this->phone);
    if (!preg_match('/\d{10}/', $stripToDigits)) {
      return [
        'result' => false,
        'message' =>
          'Phone must contain 10 digits, but formatting does not matter.'
      ];
    }
    $selector = ['&',
        'strict' => ['phone', $stripToDigits]
      ];
    if (isset($this->guid)) {
      $selector['!guid'] = $this->guid;
    }
    $test = Nymph::getEntity(
        ['class' => '\Tilmeld\Entities\User', 'skip_ac' => true],
        $selector
    );
    if (isset($test->guid)) {
      return ['result' => false, 'message' => 'Phone number is in use.'];
    }

    return [
      'result' => true,
      'message' => (
        isset($this->guid) ? 'Phone number is valid.' : 'Phone number is valid!'
      )
    ];
  }
public function checkPhone ( ) { if ( empty ( $ this -> phone ) ) { return [ 'result' => false , 'message' => 'Please specify a phone number.' ] ; } $ stripToDigits = preg_replace ( '/\D/' , '' , $ this -> phone ) ; if ( ! preg_match ( '/\d{10}/' , $ stripToDigits ) ) { return [ 'result' => false , 'message' => 'Phone must contain 10 digits, but formatting does not matter.' ] ; } $ selector = [ '&' , 'strict' => [ 'phone' , $ stripToDigits ] ] ; if ( isset ( $ this -> guid ) ) { $ selector [ '!guid' ] = $ this -> guid ; } $ test = Nymph :: getEntity ( [ 'class' => '\Tilmeld\Entities\User' , 'skip_ac' => true ] , $ selector ) ; if ( isset ( $ test -> guid ) ) { return [ 'result' => false , 'message' => 'Phone number is in use.' ] ; } return [ 'result' => true , 'message' => ( isset ( $ this -> guid ) ? 'Phone number is valid.' : 'Phone number is valid!' ) ] ; }
Check that a phone number is unique.

@return array An associative array with a boolean 'result' entry and a
'message' entry.
Check that a phone number is unique .