Skip to content

Commit

Permalink
Merge pull request #92 from ker0x/hotfix/issue-90
Browse files Browse the repository at this point in the history
[#90] Remove Singleton design pattern on Api class
  • Loading branch information
ker0x authored Mar 18, 2018
2 parents 5e05f0d + 194bcee commit 7d94e69
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 255 deletions.
32 changes: 0 additions & 32 deletions src/Api/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,13 @@

namespace Kerox\Messenger\Api;

use GuzzleHttp\ClientInterface;
use Kerox\Messenger\Request\CodeRequest;
use Kerox\Messenger\Response\CodeResponse;

class Code extends AbstractApi
{
const CODE_TYPE_STANDARD = 'standard';

/**
* @var null|\Kerox\Messenger\Api\Code
*/
private static $_instance;

/**
* Code constructor.
*
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*/
public function __construct(string $pageToken, ClientInterface $client)
{
parent::__construct($pageToken, $client);
}

/**
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*
* @return \Kerox\Messenger\Api\Code
*/
public static function getInstance(string $pageToken, ClientInterface $client): self
{
if (self::$_instance === null) {
self::$_instance = new self($pageToken, $client);
}

return self::$_instance;
}

/**
* @param int $imageSize
* @param string $codeType
Expand Down
32 changes: 0 additions & 32 deletions src/Api/Insights.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,11 @@

namespace Kerox\Messenger\Api;

use GuzzleHttp\ClientInterface;
use Kerox\Messenger\Request\InsightsRequest;
use Kerox\Messenger\Response\InsightsResponse;

class Insights extends AbstractApi
{
/**
* @var null|\Kerox\Messenger\Api\Insights
*/
private static $_instance;

/**
* Insights constructor.
*
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*/
public function __construct(string $pageToken, ClientInterface $client)
{
parent::__construct($pageToken, $client);
}

/**
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*
* @return \Kerox\Messenger\Api\Insights
*/
public static function getInstance(string $pageToken, ClientInterface $client): self
{
if (self::$_instance === null) {
self::$_instance = new self($pageToken, $client);
}

return self::$_instance;
}

/**
* @return \Kerox\Messenger\Response\InsightsResponse
*/
Expand Down
32 changes: 0 additions & 32 deletions src/Api/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,13 @@

namespace Kerox\Messenger\Api;

use GuzzleHttp\ClientInterface;
use Kerox\Messenger\Model\ProfileSettings;
use Kerox\Messenger\ProfileInterface;
use Kerox\Messenger\Request\ProfileRequest;
use Kerox\Messenger\Response\ProfileResponse;

class Profile extends AbstractApi implements ProfileInterface
{
/**
* @var null|\Kerox\Messenger\Api\Profile
*/
private static $_instance;

/**
* Profile constructor.
*
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*/
public function __construct($pageToken, ClientInterface $client)
{
parent::__construct($pageToken, $client);
}

/**
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*
* @return \Kerox\Messenger\Api\Profile
*/
public static function getInstance(string $pageToken, ClientInterface $client): self
{
if (self::$_instance === null) {
self::$_instance = new self($pageToken, $client);
}

return self::$_instance;
}

/**
* @param \Kerox\Messenger\Model\ProfileSettings $profileSettings
*
Expand Down
32 changes: 0 additions & 32 deletions src/Api/Send.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Kerox\Messenger\Api;

use GuzzleHttp\ClientInterface;
use Kerox\Messenger\Model\Message;
use Kerox\Messenger\Model\Message\Attachment;
use Kerox\Messenger\Request\SendRequest;
Expand Down Expand Up @@ -30,37 +29,6 @@ class Send extends AbstractApi
const TAG_PAYMENT_UPDATE = 'PAYMENT_UPDATE';
const TAG_PERSONAL_FINANCE_UPDATE = 'PERSONAL_FINANCE_UPDATE';

/**
* @var null|\Kerox\Messenger\Api\Send
*/
private static $_instance;

/**
* Send constructor.
*
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*/
public function __construct(string $pageToken, ClientInterface $client)
{
parent::__construct($pageToken, $client);
}

/**
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*
* @return \Kerox\Messenger\Api\Send
*/
public static function getInstance(string $pageToken, ClientInterface $client): self
{
if (self::$_instance === null) {
self::$_instance = new self($pageToken, $client);
}

return self::$_instance;
}

/**
* @param string $recipient
* @param string|\Kerox\Messenger\Model\Message $message
Expand Down
32 changes: 0 additions & 32 deletions src/Api/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,11 @@

namespace Kerox\Messenger\Api;

use GuzzleHttp\ClientInterface;
use Kerox\Messenger\Request\TagRequest;
use Kerox\Messenger\Response\TagResponse;

class Tag extends AbstractApi
{
/**
* @var null|\Kerox\Messenger\Api\Tag
*/
private static $_instance;

/**
* Tag constructor.
*
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*/
public function __construct(string $pageToken, ClientInterface $client)
{
parent::__construct($pageToken, $client);
}

/**
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*
* @return \Kerox\Messenger\Api\Tag
*/
public static function getInstance(string $pageToken, ClientInterface $client): self
{
if (self::$_instance === null) {
self::$_instance = new self($pageToken, $client);
}

return self::$_instance;
}

/**
* @return \Kerox\Messenger\Response\TagResponse
*/
Expand Down
32 changes: 0 additions & 32 deletions src/Api/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,12 @@

namespace Kerox\Messenger\Api;

use GuzzleHttp\ClientInterface;
use Kerox\Messenger\Model\ThreadControl;
use Kerox\Messenger\Request\ThreadRequest;
use Kerox\Messenger\Response\ThreadResponse;

class Thread extends AbstractApi
{
/**
* @var null|\Kerox\Messenger\Api\Thread
*/
private static $_instance;

/**
* Send constructor.
*
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*/
public function __construct(string $pageToken, ClientInterface $client)
{
parent::__construct($pageToken, $client);
}

/**
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*
* @return \Kerox\Messenger\Api\Thread
*/
public static function getInstance(string $pageToken, ClientInterface $client): self
{
if (self::$_instance === null) {
self::$_instance = new self($pageToken, $client);
}

return self::$_instance;
}

/**
* @param \Kerox\Messenger\Model\ThreadControl $threadControl
*
Expand Down
32 changes: 0 additions & 32 deletions src/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,12 @@

namespace Kerox\Messenger\Api;

use GuzzleHttp\ClientInterface;
use Kerox\Messenger\Request\UserRequest;
use Kerox\Messenger\Response\UserResponse;
use Kerox\Messenger\UserInterface;

class User extends AbstractApi implements UserInterface
{
/**
* @var null|\Kerox\Messenger\Api\User
*/
private static $_instance;

/**
* Send constructor.
*
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*/
public function __construct(string $pageToken, ClientInterface $client)
{
parent::__construct($pageToken, $client);
}

/**
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
*
* @return \Kerox\Messenger\Api\User
*/
public static function getInstance(string $pageToken, ClientInterface $client): self
{
if (self::$_instance === null) {
self::$_instance = new self($pageToken, $client);
}

return self::$_instance;
}

/**
* @param string $userId
* @param array|null $fields
Expand Down
23 changes: 0 additions & 23 deletions src/Api/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

class Webhook extends AbstractApi
{
/**
* @var null|\Kerox\Messenger\Api\Webhook
*/
private static $_instance;

/**
* @var string
*/
Expand Down Expand Up @@ -64,24 +59,6 @@ public function __construct(string $appSecret, string $verifyToken, string $page
$this->request = $request ?: ServerRequest::fromGlobals();
}

/**
* @param string $appSecret
* @param string $verifyToken
* @param string $pageToken
* @param \GuzzleHttp\ClientInterface $client
* @param \Psr\Http\Message\ServerRequestInterface $request
*
* @return \Kerox\Messenger\Api\Webhook
*/
public static function getInstance(string $appSecret, string $verifyToken, string $pageToken, ClientInterface $client, ServerRequestInterface $request = null): self
{
if (self::$_instance === null) {
self::$_instance = new self($appSecret, $verifyToken, $pageToken, $client, $request);
}

return self::$_instance;
}

/**
* @return bool
*/
Expand Down
Loading

0 comments on commit 7d94e69

Please sign in to comment.