for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace diecoding\aws\s3\handlers;
use Aws\CommandInterface as AwsCommand;
use diecoding\aws\s3\base\handlers\Handler;
use diecoding\aws\s3\interfaces\commands\Asynchronous;
use diecoding\aws\s3\interfaces\commands\PlainCommand;
/**
* Class PlainCommandHandler
*
* @package diecoding\aws\s3\handlers
*/
final class PlainCommandHandler extends Handler
{
* @param \diecoding\aws\s3\interfaces\commands\PlainCommand $command
* @return \Aws\ResultInterface|\GuzzleHttp\Promise\PromiseInterface
public function handle(PlainCommand $command)
$awsCommand = $this->transformToAwsCommand($command);
/** @var \GuzzleHttp\Promise\PromiseInterface $promise */
$promise = $this->s3Client->executeAsync($awsCommand);
return $this->commandIsAsync($command) ? $promise : $promise->wait();
}
* @return bool
protected function commandIsAsync(PlainCommand $command): bool
return $command instanceof Asynchronous && $command->isAsync();
* @return \Aws\CommandInterface
protected function transformToAwsCommand(PlainCommand $command): AwsCommand
$args = array_filter($command->toArgs());
return $this->s3Client->getCommand($command->getName(), $args);