CoreFiles by mySites.guru
WithRequestAuthenticationTrait.php40 lines, 1,201 bytes, from wordpress-7.0.zip
Raw History Compare with 6.9.11
md5
a5d577de5d4887692c34a1d7558cdf78
sha1
07f84def929f616b648caa6c664b13d0589480f6
sha256
af0600e33cc1db5405ef235b4879e69c3149709015d76a28155ff4b592cdb553
<?php

declare (strict_types=1);
namespace WordPress\AiClient\Providers\Http\Traits;

use WordPress\AiClient\Common\Exception\RuntimeException;
use WordPress\AiClient\Providers\Http\Contracts\RequestAuthenticationInterface;
/**
 * Trait for a class that implements WithRequestAuthenticationInterface.
 *
 * @since 0.1.0
 */
trait WithRequestAuthenticationTrait
{
    /**
     * @var RequestAuthenticationInterface|null The request authentication instance.
     */
    private ?RequestAuthenticationInterface $requestAuthentication = null;
    /**
     * {@inheritDoc}
     *
     * @since 0.1.0
     */
    public function setRequestAuthentication(RequestAuthenticationInterface $requestAuthentication): void
    {
        $this->requestAuthentication = $requestAuthentication;
    }
    /**
     * {@inheritDoc}
     *
     * @since 0.1.0
     */
    public function getRequestAuthentication(): RequestAuthenticationInterface
    {
        if ($this->requestAuthentication === null) {
            throw new RuntimeException('RequestAuthenticationInterface instance not set. ' . 'Make sure you use the AiClient class for all requests.');
        }
        return $this->requestAuthentication;
    }
}

The same content is in 40 releases, WordPress 7.0-beta1 to 7.2-beta5. See them all, or every version of this file.