Source of file Command.php

Size: 1,881 Bytes - Last Modified: 2018-11-03T09:50:48-04:00

G:/AdobeConnectClient/src/Command.php

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
<?php

namespace AdobeConnectClient;

use BadMethodCallException;
use UnexpectedValueException;
use InvalidArgumentException;
use DomainException;
use AdobeConnectClient\Exceptions\InvalidException;
use AdobeConnectClient\Exceptions\NoAccessException;
use AdobeConnectClient\Exceptions\NoDataException;
use AdobeConnectClient\Exceptions\TooMuchDataException;

/**
 * The Commands base class is an abstraction to Web Service actions
 *
 * Need set the Client dependency to execute the command.
 * For a list of actions see {@link https://helpx.adobe.com/adobe-connect/webservices/topics/action-reference.html}
 *
 * @todo Create all items
 */
abstract class Command
{
    /**
     * @var Client
     */
    protected $client;

    /**
     * @param Client $client
     * @return Command
     */
    public function setClient(Client $client)
    {
        $this->client = $client;
        return $this;
    }

    /**
     * Executes the command and return a value
     *
     * @return mixed
     * @throws InvalidException
     * @throws NoAccessException
     * @throws NoDataException
     * @throws TooMuchDataException
     * @throws UnexpectedValueException
     * @throws InvalidArgumentException
     * @throws DomainException
     * @throws BadMethodCallException
     */
    public function execute()
    {
        if (!($this->client instanceof Client)) {
            throw new BadMethodCallException('Needs the Client to execute a Command');
        }
        return $this->process();
    }

    /**
     * Process the command and return a value
     *
     * @return mixed
     * @throws InvalidException
     * @throws NoAccessException
     * @throws NoDataException
     * @throws TooMuchDataException
     * @throws UnexpectedValueException
     * @throws InvalidArgumentException
     * @throws DomainException
     */
    abstract protected function process();
}