1
0

refactoring of commands. now they are semantic

This commit is contained in:
frostealth
2016-10-08 00:17:22 +06:00
parent 55fa650f52
commit b4d9605bdc
17 changed files with 142 additions and 138 deletions

View File

@@ -49,11 +49,11 @@ $s3 = Yii::$app->get('s3');
/** @var \Aws\ResultInterface $result */ /** @var \Aws\ResultInterface $result */
$result = $s3->commands()->get('filename.ext')->saveAs('/path/to/local/file.ext')->execute(); $result = $s3->commands()->get('filename.ext')->saveAs('/path/to/local/file.ext')->execute();
$result = $s3->commands()->put('filename.ext', 'body')->setContentType('text/plain')->execute(); $result = $s3->commands()->put('filename.ext', 'body')->withContentType('text/plain')->execute();
$result = $s3->commands()->delete('filename.ext')->execute(); $result = $s3->commands()->delete('filename.ext')->execute();
$result = $s3->commands()->upload('filename.ext', '/path/to/local/file.ext')->setAcl('private')->execute(); $result = $s3->commands()->upload('filename.ext', '/path/to/local/file.ext')->withAcl('private')->execute();
$result = $s3->commands()->restore('filename.ext', $days = 7)->execute(); $result = $s3->commands()->restore('filename.ext', $days = 7)->execute();
@@ -118,7 +118,7 @@ $s3 = Yii::$app->get('s3');
/** @var \frostealth\yii2\aws\s3\commands\GetCommand $command */ /** @var \frostealth\yii2\aws\s3\commands\GetCommand $command */
$command = $s3->create(GetCommand::class); $command = $s3->create(GetCommand::class);
$command->setBucket('my-another-bucket')->setFilename('filename.ext')->saveAs('/path/to/local/file.ext'); $command->inBucket('my-another-bucket')->byFilename('filename.ext')->saveAs('/path/to/local/file.ext');
/** @var \Aws\ResultInterface $result */ /** @var \Aws\ResultInterface $result */
$result = $s3->execute($command); $result = $s3->execute($command);
@@ -169,7 +169,7 @@ class MyCommand implements Command, HasBucket
return $this->bucket; return $this->bucket;
} }
public function setBucket(string $bucket) public function inBucket(string $bucket)
{ {
$this->bucket = $bucket; $this->bucket = $bucket;
@@ -181,7 +181,7 @@ class MyCommand implements Command, HasBucket
return $this->something; return $this->something;
} }
public function setSomething(string $something) public function withSomething(string $something)
{ {
$this->something = $something; $this->something = $something;
@@ -221,7 +221,7 @@ $s3 = Yii::$app->get('s3');
/** @var \app\components\s3\commands\MyCommand $command */ /** @var \app\components\s3\commands\MyCommand $command */
$command = $s3->create(MyCommand::class); $command = $s3->create(MyCommand::class);
$command->setSomething('some value')->setOption('OptionName', 'value'); $command->withSomething('some value')->withOption('OptionName', 'value');
/** @var \Aws\ResultInterface $result */ /** @var \Aws\ResultInterface $result */
$result = $s3->execute($command); $result = $s3->execute($command);
@@ -234,8 +234,8 @@ Custom plain command looks like this:
namespace app\components\s3\commands; namespace app\components\s3\commands;
use frostealth\yii2\aws\s3\interfaces\HasBucket; use frostealth\yii2\aws\s3\interfaces\commands\HasBucket;
use frostealth\yii2\aws\s3\interfaces\PlainCommand; use frostealth\yii2\aws\s3\interfaces\commands\PlainCommand;
class MyPlainCommand implements PlainCommand, HasBucket class MyPlainCommand implements PlainCommand, HasBucket
{ {
@@ -246,7 +246,7 @@ class MyPlainCommand implements PlainCommand, HasBucket
return $this->args['Bucket'] ?? ''; return $this->args['Bucket'] ?? '';
} }
public function setBucket(string $bucket) public function inBucket(string $bucket)
{ {
$this->args['Bucket'] = $bucket; $this->args['Bucket'] = $bucket;
@@ -258,7 +258,7 @@ class MyPlainCommand implements PlainCommand, HasBucket
return $this->args['something'] ?? ''; return $this->args['something'] ?? '';
} }
public function setSomething($something) public function withSomething($something)
{ {
$this->args['something'] = $something; $this->args['something'] = $something;
@@ -278,7 +278,7 @@ class MyPlainCommand implements PlainCommand, HasBucket
``` ```
Any command can extend the `ExecutableCommand` class or implement the `Executable` interface that will Any command can extend the `ExecutableCommand` class or implement the `Executable` interface that will
allow to execute this command immediately: `$command->setSomething('some value')->execute();`. allow to execute this command immediately: `$command->withSomething('some value')->execute();`.
## License ## License

View File

@@ -58,11 +58,11 @@ class CommandBuilder implements interfaces\CommandBuilder
protected function prepareCommand(interfaces\commands\Command $command) protected function prepareCommand(interfaces\commands\Command $command)
{ {
if ($command instanceof interfaces\commands\HasBucket) { if ($command instanceof interfaces\commands\HasBucket) {
$command->setBucket($this->bucket); $command->inBucket($this->bucket);
} }
if ($command instanceof interfaces\commands\HasAcl) { if ($command instanceof interfaces\commands\HasAcl) {
$command->setAcl($this->acl); $command->withAcl($this->acl);
} }
} }
} }

View File

@@ -41,7 +41,7 @@ class CommandFactory
{ {
/** @var GetCommand $command */ /** @var GetCommand $command */
$command = $this->builder->build(GetCommand::class); $command = $this->builder->build(GetCommand::class);
$command->setFilename($filename); $command->byFilename($filename);
return $command; return $command;
} }
@@ -56,7 +56,7 @@ class CommandFactory
{ {
/** @var PutCommand $command */ /** @var PutCommand $command */
$command = $this->builder->build(PutCommand::class); $command = $this->builder->build(PutCommand::class);
$command->setFilename($filename)->setBody($body); $command->withFilename($filename)->withBody($body);
return $command; return $command;
} }
@@ -70,7 +70,7 @@ class CommandFactory
{ {
/** @var DeleteCommand $command */ /** @var DeleteCommand $command */
$command = $this->builder->build(DeleteCommand::class); $command = $this->builder->build(DeleteCommand::class);
$command->setFilename($filename); $command->byFilename($filename);
return $command; return $command;
} }
@@ -85,7 +85,7 @@ class CommandFactory
{ {
/** @var UploadCommand $command */ /** @var UploadCommand $command */
$command = $this->builder->build(UploadCommand::class); $command = $this->builder->build(UploadCommand::class);
$command->setFilename($filename)->setSource($source); $command->withFilename($filename)->withSource($source);
return $command; return $command;
} }
@@ -100,7 +100,7 @@ class CommandFactory
{ {
/** @var RestoreCommand $command */ /** @var RestoreCommand $command */
$command = $this->builder->build(RestoreCommand::class); $command = $this->builder->build(RestoreCommand::class);
$command->setFilename($filename)->setDays($days); $command->byFilename($filename)->withLifetime($days);
return $command; return $command;
} }
@@ -114,7 +114,7 @@ class CommandFactory
{ {
/** @var ExistCommand $command */ /** @var ExistCommand $command */
$command = $this->builder->build(ExistCommand::class); $command = $this->builder->build(ExistCommand::class);
$command->setFilename($filename); $command->byFilename($filename);
return $command; return $command;
} }
@@ -128,7 +128,7 @@ class CommandFactory
{ {
/** @var GetUrlCommand $command */ /** @var GetUrlCommand $command */
$command = $this->builder->build(GetUrlCommand::class); $command = $this->builder->build(GetUrlCommand::class);
$command->setFilename($filename); $command->byFilename($filename);
return $command; return $command;
} }
@@ -143,7 +143,7 @@ class CommandFactory
{ {
/** @var GetPresignedUrlCommand $command */ /** @var GetPresignedUrlCommand $command */
$command = $this->builder->build(GetPresignedUrlCommand::class); $command = $this->builder->build(GetPresignedUrlCommand::class);
$command->setFilename($filename)->setExpires($expires); $command->byFilename($filename)->withExpiration($expires);
return $command; return $command;
} }

View File

@@ -17,7 +17,7 @@ trait Options
* *
* @return $this * @return $this
*/ */
final public function setOptions(array $value) final public function withOptions(array $value)
{ {
$this->options = $value; $this->options = $value;
@@ -38,7 +38,7 @@ trait Options
* *
* @return $this * @return $this
*/ */
final public function setOption(string $name, $value) final public function withOption(string $name, $value)
{ {
$this->options[$name] = $value; $this->options[$name] = $value;

View File

@@ -35,13 +35,13 @@ class DeleteCommand extends ExecutableCommand implements PlainCommand, HasBucket
} }
/** /**
* @param string $bucket * @param string $name
* *
* @return $this * @return $this
*/ */
public function setBucket(string $bucket) public function inBucket(string $name)
{ {
$this->args['Bucket'] = $bucket; $this->args['Bucket'] = $name;
return $this; return $this;
} }
@@ -59,7 +59,7 @@ class DeleteCommand extends ExecutableCommand implements PlainCommand, HasBucket
* *
* @return $this * @return $this
*/ */
public function setFilename(string $filename) public function byFilename(string $filename)
{ {
$this->args['Key'] = $filename; $this->args['Key'] = $filename;
@@ -79,7 +79,7 @@ class DeleteCommand extends ExecutableCommand implements PlainCommand, HasBucket
* *
* @return $this * @return $this
*/ */
public function setVersionId(string $versionId) public function withVersionId(string $versionId)
{ {
$this->args['VersionId'] = $versionId; $this->args['VersionId'] = $versionId;
@@ -87,6 +87,8 @@ class DeleteCommand extends ExecutableCommand implements PlainCommand, HasBucket
} }
/** /**
* @internal used by the handlers
*
* @return string * @return string
*/ */
public function getName(): string public function getName(): string
@@ -95,6 +97,8 @@ class DeleteCommand extends ExecutableCommand implements PlainCommand, HasBucket
} }
/** /**
* @internal used by the handlers
*
* @return array * @return array
*/ */
public function toArgs(): array public function toArgs(): array

View File

@@ -32,13 +32,13 @@ class ExistCommand extends ExecutableCommand implements HasBucket
} }
/** /**
* @param string $bucket * @param string $name
* *
* @return $this * @return $this
*/ */
public function setBucket(string $bucket) public function inBucket(string $name)
{ {
$this->bucket = $bucket; $this->bucket = $name;
return $this; return $this;
} }
@@ -56,7 +56,7 @@ class ExistCommand extends ExecutableCommand implements HasBucket
* *
* @return $this * @return $this
*/ */
public function setFilename(string $filename) public function byFilename(string $filename)
{ {
$this->filename = $filename; $this->filename = $filename;

View File

@@ -35,13 +35,13 @@ class GetCommand extends ExecutableCommand implements PlainCommand, HasBucket, A
} }
/** /**
* @param string $bucket * @param string $name
* *
* @return $this * @return $this
*/ */
public function setBucket(string $bucket) public function inBucket(string $name)
{ {
$this->args['Bucket'] = $bucket; $this->args['Bucket'] = $name;
return $this; return $this;
} }
@@ -59,7 +59,7 @@ class GetCommand extends ExecutableCommand implements PlainCommand, HasBucket, A
* *
* @return $this * @return $this
*/ */
public function setFilename(string $filename) public function byFilename(string $filename)
{ {
$this->args['Key'] = $filename; $this->args['Key'] = $filename;
@@ -91,6 +91,8 @@ class GetCommand extends ExecutableCommand implements PlainCommand, HasBucket, A
} }
/** /**
* @internal used by the handlers
*
* @return string * @return string
*/ */
public function getName(): string public function getName(): string
@@ -99,6 +101,8 @@ class GetCommand extends ExecutableCommand implements PlainCommand, HasBucket, A
} }
/** /**
* @internal used by the handlers
*
* @return array * @return array
*/ */
public function toArgs(): array public function toArgs(): array

View File

@@ -18,7 +18,7 @@ class GetPresignedUrlCommand extends ExecutableCommand implements HasBucket
protected $args = []; protected $args = [];
/** @var mixed */ /** @var mixed */
protected $expires; protected $expiration;
/** /**
* @return string * @return string
@@ -29,13 +29,13 @@ class GetPresignedUrlCommand extends ExecutableCommand implements HasBucket
} }
/** /**
* @param string $bucket * @param string $name
* *
* @return $this * @return $this
*/ */
public function setBucket(string $bucket) public function inBucket(string $name)
{ {
$this->args['Bucket'] = $bucket; $this->args['Bucket'] = $name;
return $this; return $this;
} }
@@ -53,7 +53,7 @@ class GetPresignedUrlCommand extends ExecutableCommand implements HasBucket
* *
* @return $this * @return $this
*/ */
public function setFilename(string $filename) public function byFilename(string $filename)
{ {
$this->args['Key'] = $filename; $this->args['Key'] = $filename;
@@ -63,24 +63,26 @@ class GetPresignedUrlCommand extends ExecutableCommand implements HasBucket
/** /**
* @return mixed * @return mixed
*/ */
public function getExpires() public function getExpiration()
{ {
return $this->expires; return $this->expiration;
} }
/** /**
* @param int|string|\DateTime $expires * @param int|string|\DateTime $expiration
* *
* @return $this * @return $this
*/ */
public function setExpires($expires) public function withExpiration($expiration)
{ {
$this->expires = $expires; $this->expiration = $expiration;
return $this; return $this;
} }
/** /**
* @internal used by the handlers
*
* @return array * @return array
*/ */
public function getArgs(): array public function getArgs(): array

View File

@@ -29,13 +29,13 @@ class GetUrlCommand extends ExecutableCommand implements HasBucket
} }
/** /**
* @param string $bucket * @param string $name
* *
* @return $this * @return $this
*/ */
public function setBucket(string $bucket) public function inBucket(string $name)
{ {
$this->bucket = $bucket; $this->bucket = $name;
return $this; return $this;
} }
@@ -53,7 +53,7 @@ class GetUrlCommand extends ExecutableCommand implements HasBucket
* *
* @return $this * @return $this
*/ */
public function setFilename(string $filename) public function byFilename(string $filename)
{ {
$this->filename = $filename; $this->filename = $filename;

View File

@@ -36,13 +36,13 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
} }
/** /**
* @param string $bucket * @param string $name
* *
* @return $this * @return $this
*/ */
public function setBucket(string $bucket) public function inBucket(string $name)
{ {
$this->args['Bucket'] = $bucket; $this->args['Bucket'] = $name;
return $this; return $this;
} }
@@ -60,7 +60,7 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
* *
* @return $this * @return $this
*/ */
public function setFilename(string $filename) public function withFilename(string $filename)
{ {
$this->args['Key'] = $filename; $this->args['Key'] = $filename;
@@ -80,7 +80,7 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
* *
* @return $this * @return $this
*/ */
public function setAcl(string $acl) public function withAcl(string $acl)
{ {
$this->args['ACL'] = $acl; $this->args['ACL'] = $acl;
@@ -100,7 +100,7 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
* *
* @return $this * @return $this
*/ */
public function setBody($body) public function withBody($body)
{ {
$this->args['Body'] = $body; $this->args['Body'] = $body;
@@ -120,7 +120,7 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
* *
* @return $this * @return $this
*/ */
public function setMetadata(array $metadata) public function withMetadata(array $metadata)
{ {
$this->args['Metadata'] = $metadata; $this->args['Metadata'] = $metadata;
@@ -140,7 +140,7 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
* *
* @return $this * @return $this
*/ */
public function setContentType(string $contentType) public function withContentType(string $contentType)
{ {
$this->args['ContentType'] = $contentType; $this->args['ContentType'] = $contentType;
@@ -150,7 +150,7 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
/** /**
* @return mixed * @return mixed
*/ */
public function getExpires() public function getExpiration()
{ {
return $this->args['Expires'] ?? null; return $this->args['Expires'] ?? null;
} }
@@ -160,7 +160,7 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
* *
* @return $this * @return $this
*/ */
public function setExpires($expires) public function withExpiration($expires)
{ {
$this->args['Expires'] = $expires; $this->args['Expires'] = $expires;
@@ -168,6 +168,8 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
} }
/** /**
* @internal used by the handlers
*
* @return string * @return string
*/ */
public function getName(): string public function getName(): string
@@ -176,6 +178,8 @@ class PutCommand extends ExecutableCommand implements PlainCommand, HasBucket, H
} }
/** /**
* @internal used by the handlers
*
* @return array * @return array
*/ */
public function toArgs(): array public function toArgs(): array

View File

@@ -33,13 +33,13 @@ class RestoreCommand extends ExecutableCommand implements PlainCommand, HasBucke
} }
/** /**
* @param string $bucket * @param string $name
* *
* @return $this * @return $this
*/ */
public function setBucket(string $bucket) public function inBucket(string $name)
{ {
$this->args['Bucket'] = $bucket; $this->args['Bucket'] = $name;
return $this; return $this;
} }
@@ -57,7 +57,7 @@ class RestoreCommand extends ExecutableCommand implements PlainCommand, HasBucke
* *
* @return $this * @return $this
*/ */
public function setFilename(string $filename) public function byFilename(string $filename)
{ {
$this->args['Key'] = $filename; $this->args['Key'] = $filename;
@@ -67,7 +67,7 @@ class RestoreCommand extends ExecutableCommand implements PlainCommand, HasBucke
/** /**
* @return int lifetime of the active copy in days * @return int lifetime of the active copy in days
*/ */
public function getDays(): int public function getLifetime(): int
{ {
return $this->args['Days'] ?? 0; return $this->args['Days'] ?? 0;
} }
@@ -77,7 +77,7 @@ class RestoreCommand extends ExecutableCommand implements PlainCommand, HasBucke
* *
* @return $this * @return $this
*/ */
public function setDays(int $days) public function withLifetime(int $days)
{ {
$this->args['Days'] = $days; $this->args['Days'] = $days;
@@ -97,7 +97,7 @@ class RestoreCommand extends ExecutableCommand implements PlainCommand, HasBucke
* *
* @return $this * @return $this
*/ */
public function setVersionId(string $versionId) public function withVersionId(string $versionId)
{ {
$this->args['VersionId'] = $versionId; $this->args['VersionId'] = $versionId;
@@ -105,6 +105,8 @@ class RestoreCommand extends ExecutableCommand implements PlainCommand, HasBucke
} }
/** /**
* @internal used by the handlers
*
* @return string * @return string
*/ */
public function getName(): string public function getName(): string
@@ -113,6 +115,8 @@ class RestoreCommand extends ExecutableCommand implements PlainCommand, HasBucke
} }
/** /**
* @internal used by the handlers
*
* @return array * @return array
*/ */
public function toArgs(): array public function toArgs(): array

View File

@@ -45,13 +45,13 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
} }
/** /**
* @param string $bucket * @param string $name
* *
* @return $this * @return $this
*/ */
public function setBucket(string $bucket) public function inBucket(string $name)
{ {
$this->bucket = $bucket; $this->bucket = $name;
return $this; return $this;
} }
@@ -69,7 +69,7 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
* *
* @return $this * @return $this
*/ */
public function setAcl(string $acl) public function withAcl(string $acl)
{ {
$this->acl = $acl; $this->acl = $acl;
@@ -89,7 +89,7 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
* *
* @return $this * @return $this
*/ */
public function setSource($source) public function withSource($source)
{ {
$this->source = $source; $this->source = $source;
@@ -109,7 +109,7 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
* *
* @return $this * @return $this
*/ */
public function setFilename(string $filename) public function withFilename(string $filename)
{ {
$this->filename = $filename; $this->filename = $filename;
@@ -129,7 +129,7 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
* *
* @return $this * @return $this
*/ */
public function setPartSize(int $partSize) public function withPartSize(int $partSize)
{ {
$this->options['part_size'] = $partSize; $this->options['part_size'] = $partSize;
@@ -149,7 +149,7 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
* *
* @return $this * @return $this
*/ */
public function setConcurrency(int $concurrency) public function withConcurrency(int $concurrency)
{ {
$this->options['concurrency'] = $concurrency; $this->options['concurrency'] = $concurrency;
@@ -169,7 +169,7 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
* *
* @return $this * @return $this
*/ */
public function setMupThreshold(int $mupThreshold) public function withMupThreshold(int $mupThreshold)
{ {
$this->options['mup_threshold'] = $mupThreshold; $this->options['mup_threshold'] = $mupThreshold;
@@ -189,11 +189,9 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
* *
* @return $this * @return $this
*/ */
public function setContentType(string $contentType) public function withContentType(string $contentType)
{ {
$this->setParam('ContentType', $contentType); return $this->withParam('ContentType', $contentType);
return $this;
} }
/** /**
@@ -209,37 +207,35 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
* *
* @return $this * @return $this
*/ */
public function setContentDisposition(string $contentDisposition) public function withContentDisposition(string $contentDisposition)
{ {
$this->setParam('ContentDisposition', $contentDisposition); return $this->withParam('ContentDisposition', $contentDisposition);
}
/**
* @param string $name
* @param mixed $default
*
* @return mixed
*/
public function getParam(string $name, $default = null)
{
return $this->options['params'][$name] ?? $default;
}
/**
* @param string $name
* @param mixed $value
*
* @return $this
*/
public function withParam(string $name, $value)
{
$this->options['params'][$name] = $value;
return $this; return $this;
} }
/**
* @return array
*/
public function getParams(): array
{
return $this->options['params'] ?? [];
}
/**
* @param array $params
*/
public function setParams(array $params)
{
$this->options['params'] = $params;
}
/**
* @return array
*/
public function getOptions(): array
{
return $this->options;
}
/** /**
* @param callable $beforeUpload * @param callable $beforeUpload
* *
@@ -253,22 +249,12 @@ class UploadCommand extends ExecutableCommand implements HasBucket, HasAcl, Asyn
} }
/** /**
* @param string $name * @internal used by the handlers
* @param mixed $default
* *
* @return mixed * @return array
*/ */
protected function getParam(string $name, $default) public function getOptions(): array
{ {
return $this->options['params'][$name] ?? $default; return $this->options;
}
/**
* @param string $name
* @param mixed $value
*/
protected function setParam(string $name, $value)
{
$this->options['params'][$name] = $value;
} }
} }

View File

@@ -20,7 +20,7 @@ final class GetPresignedUrlCommandHandler extends Handler
public function handle(GetPresignedUrlCommand $command): string public function handle(GetPresignedUrlCommand $command): string
{ {
$awsCommand = $this->s3Client->getCommand('GetObject', $command->getArgs()); $awsCommand = $this->s3Client->getCommand('GetObject', $command->getArgs());
$request = $this->s3Client->createPresignedRequest($awsCommand, $command->getExpires()); $request = $this->s3Client->createPresignedRequest($awsCommand, $command->getExpiration());
return (string)$request->getUri(); return (string)$request->getUri();
} }

View File

@@ -21,7 +21,7 @@ final class PlainCommandHandler extends Handler
*/ */
public function handle(PlainCommand $command) public function handle(PlainCommand $command)
{ {
$awsCommand = $this->toAwsCommand($command); $awsCommand = $this->transformToAwsCommand($command);
/** @var \GuzzleHttp\Promise\PromiseInterface $promise */ /** @var \GuzzleHttp\Promise\PromiseInterface $promise */
$promise = $this->s3Client->executeAsync($awsCommand); $promise = $this->s3Client->executeAsync($awsCommand);
@@ -44,7 +44,7 @@ final class PlainCommandHandler extends Handler
* *
* @return \Aws\CommandInterface * @return \Aws\CommandInterface
*/ */
protected function toAwsCommand(PlainCommand $command): AwsCommand protected function transformToAwsCommand(PlainCommand $command): AwsCommand
{ {
$args = array_filter($command->toArgs()); $args = array_filter($command->toArgs());

View File

@@ -21,7 +21,7 @@ final class UploadCommandHandler extends Handler
*/ */
public function handle(UploadCommand $command) public function handle(UploadCommand $command)
{ {
$source = $this->toStream($command->getSource()); $source = $this->sourceToStream($command->getSource());
$options = array_filter($command->getOptions()); $options = array_filter($command->getOptions());
$promise = $this->s3Client->uploadAsync( $promise = $this->s3Client->uploadAsync(
@@ -42,7 +42,7 @@ final class UploadCommandHandler extends Handler
* *
* @return StreamInterface * @return StreamInterface
*/ */
protected function toStream($source): StreamInterface protected function sourceToStream($source): StreamInterface
{ {
if (is_string($source)) { if (is_string($source)) {
$source = Psr7\try_fopen($source, 'r+'); $source = Psr7\try_fopen($source, 'r+');

View File

@@ -12,5 +12,5 @@ interface HasAcl
/** /**
* @param string $acl * @param string $acl
*/ */
public function setAcl(string $acl); public function withAcl(string $acl);
} }

View File

@@ -10,7 +10,7 @@ namespace frostealth\yii2\aws\s3\interfaces\commands;
interface HasBucket interface HasBucket
{ {
/** /**
* @param string $bucket * @param string $name
*/ */
public function setBucket(string $bucket); public function inBucket(string $name);
} }