Skip to content

Instantly share code, notes, and snippets.

@kkkw
Last active July 5, 2017 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkkw/896e806fde9becedaf4c73f594553b52 to your computer and use it in GitHub Desktop.
Save kkkw/896e806fde9becedaf4c73f594553b52 to your computer and use it in GitHub Desktop.
sample
<?php
namespace Foo\Queue\Contract;
interface Client
{
public static function get_instance();
public function message($mesage);
}
<?php
namespace Foo\Queue;
use Foo\Queue\Contract\Client;
class LocalClient implements Client
{
public static function get_instance()
{
return new static();
}
public function message($message)
{
//nothing to do on local
return false;
}
}
<?php
namespace Foo\Queue;
use Foo\Aws\Sqs\Client as AwsClient;
class Manager
{
/**
* @return \Geenie\Queue\Contract\Client
*/
public static function get_client()
{
$is_aws_active = true;
if ($is_aws_active) {
return AwsClient::get_instance();
} else {
return LocalClient::get_instance();
}
}
}
<?php
namespace Foo\Aws\Sqs;
use Foo\Queue\Contract\Client as ClientInterface;
class SqsClient implements ClientInterface
{
public static function get_instance()
{
return new static();
}
public function message($message)
{
$this->client->sendMessage($message);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment