iranianpep/botonomous

View on GitHub
src/Botonomous/AbstractSender.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Botonomous;

use Botonomous\client\ApiClient;
use Botonomous\utility\LoggerUtility;
use Botonomous\utility\MessageUtility;
use /* @noinspection PhpUndefinedClassInspection */
    GuzzleHttp\Client;

abstract class AbstractSender
{
    private $loggerUtility;
    private $messageUtility;
    private $config;
    private $apiClient;
    private $client;

    /**
     * @return LoggerUtility
     */
    public function getLoggerUtility(): LoggerUtility
    {
        if (!isset($this->loggerUtility)) {
            $this->setLoggerUtility(new LoggerUtility());
        }

        return $this->loggerUtility;
    }

    /**
     * @param LoggerUtility $loggerUtility
     */
    public function setLoggerUtility(LoggerUtility $loggerUtility)
    {
        $this->loggerUtility = $loggerUtility;
    }

    /**
     * @return Config
     */
    public function getConfig(): Config
    {
        if (!isset($this->config)) {
            $this->config = (new Config());
        }

        return $this->config;
    }

    /**
     * @param Config $config
     */
    public function setConfig(Config $config)
    {
        $this->config = $config;
    }

    /**
     * @return ApiClient
     */
    public function getApiClient(): ApiClient
    {
        if (!isset($this->apiClient)) {
            $this->setApiClient(new ApiClient());
        }

        return $this->apiClient;
    }

    /**
     * @param ApiClient $apiClient
     */
    public function setApiClient(ApiClient $apiClient)
    {
        $this->apiClient = $apiClient;
    }

    /**
     * @return Client
     */
    public function getClient(): Client
    {
        if (!isset($this->client)) {
            $this->setClient(new Client());
        }

        return $this->client;
    }

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

    /**
     * @return MessageUtility
     */
    public function getMessageUtility(): MessageUtility
    {
        if (!isset($this->messageUtility)) {
            $this->setMessageUtility(new MessageUtility());
        }

        return $this->messageUtility;
    }

    /**
     * @param MessageUtility $messageUtility
     */
    public function setMessageUtility(MessageUtility $messageUtility)
    {
        $this->messageUtility = $messageUtility;
    }
}