request = $request; if( check_ajax_referer( $nonce_name, self::NONCE_ARG, false ) ) { $this->country = $this->validate('country' ); $this->city = $this->validate('city' ); $this->code = $this->validate('code' ); } } /** * @param string $name */ private function validate( $name ) { if( isset( $this->request[ $name ] ) ) { return sanitize_text_field( wp_unslash( $this->request[ $name ] ) ); } } /** * @return string */ public function getCity() { return (string) $this->city; } /** * @return string */ public function getCode() { return (string) $this->code; } /** * @return string */ public function getCountry() { return (string) $this->country; } }