HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/shoetique/wp-content/plugins/googleanalytics/lib/class-ga-lib-api-client.php
<?php
/**
 * Google API Client.
 *
 * @package GoogleAnalytics
 */

/**
 * Google API Client.
 */
abstract class Ga_Lib_Api_Client {

	/**
	 * Keeps error messages.
	 *
	 * @var array
	 */
	protected $errors = array();

	/**
	 * Returns errors array.
	 *
	 * @return array
	 */
	public function get_errors() {
		return $this->errors;
	}

	/**
	 * Calls private API method from context client.
	 *
	 * @param callable $callback Callable function.
	 * @param array    $args     Array of arguments.
	 *
	 * @return Ga_Lib_Api_Response
	 */
	abstract public function call_api_method( $callback, $args );

	/**
	 * Calls api methods.
	 *
	 * @param string $callback Callback method name.
	 * @param mixed  $args     Arguments.
	 *
	 * @return mixed
	 */
	public function call( $callback, $args = null ) {
		try {
			delete_option( 'googleanalytics_sherethis_error_log' );
			return $this->call_api_method( $callback, $args );
		} catch ( Ga_Lib_Api_Client_Exception $e ) {
			$this->add_error( $e );

			return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
		} catch ( Ga_Lib_Api_Request_Exception $e ) {
			$this->add_error( $e );

			return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
		} catch ( Exception $e ) {
			$this->add_error( $e );

			return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
		}
	}

	/**
	 * Prepares error data.
	 *
	 * @param Exception $e Exception.
	 */
	protected function add_error( Exception $e ) {
		$this->errors[ $e->getCode() ] = array(
			'class'   => get_class( $e ),
			'message' => $e->getMessage(),
		);
		do_action( 'st_support_save_error', $e );
	}

	/**
	 * Add own error.
	 *
	 * @param string $code    Code string.
	 * @param string $message Message.
	 * @param string $class   Class name.
	 *
	 * @return void
	 */
	public function add_own_error( $code, $message, $class = '' ) {
		$this->errors[ $code ] = array(
			'class'   => $class,
			'message' => $message,
		);
	}
}