HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/agighana.org_backup/Method_Proxy_Trait.php
<?php
/**
 * Class Google\Site_Kit\Core\Util\Method_Proxy_Trait
 *
 * @package   Google\Site_Kit\Core\Util
 * @copyright 2021 Google LLC
 * @license   https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
 * @link      https://sitekit.withgoogle.com
 */

namespace Google\Site_Kit\Core\Util;

trait Method_Proxy_Trait {

	/**
	 * Gets a proxy function for a class method.
	 *
	 * @since 1.17.0
	 *
	 * @param string $method Method name.
	 * @return callable A proxy function.
	 */
	private function get_method_proxy( $method ) {
		return function ( ...$args ) use ( $method ) {
			return $this->{ $method }( ...$args );
		};
	}

	/**
	 * Gets a proxy function for a class method which can be executed only once.
	 *
	 * @since 1.24.0
	 *
	 * @param string $method Method name.
	 * @return callable A proxy function.
	 */
	private function get_method_proxy_once( $method ) {
		return function ( ...$args ) use ( $method ) {
			static $called;
			static $return_value;

			if ( ! $called ) {
				$called       = true;
				$return_value = $this->{ $method }( ...$args );
			}

			return $return_value;
		};
	}
}