thephpleague /
flysystem-aws-s3-v3
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace League\Flysystem\AwsS3V3; |
||
| 6 | |||
| 7 | use Aws\Command; |
||
| 8 | use Aws\CommandInterface; |
||
| 9 | use Aws\S3\Exception\S3Exception; |
||
| 10 | use Aws\S3\S3ClientInterface; |
||
| 11 | use Aws\S3\S3ClientTrait; |
||
| 12 | use GuzzleHttp\Psr7\Response; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @codeCoverageIgnore |
||
| 16 | */ |
||
| 17 | class S3ClientStub implements S3ClientInterface |
||
| 18 | { |
||
| 19 | use S3ClientTrait; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var S3ClientInterface |
||
| 23 | */ |
||
| 24 | private $actualClient; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var S3Exception[] |
||
| 28 | */ |
||
| 29 | private $stagedExceptions = []; |
||
| 30 | |||
| 31 | public function __construct(S3ClientInterface $client) |
||
| 32 | { |
||
| 33 | return $this->actualClient = $client; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 34 | } |
||
| 35 | |||
| 36 | public function failOnNextCopy(): void |
||
| 37 | { |
||
| 38 | $this->throwExceptionWhenExecutingCommand('CopyObject'); |
||
| 39 | } |
||
| 40 | |||
| 41 | public function throwExceptionWhenExecutingCommand(string $commandName, S3Exception $exception = null): void |
||
| 42 | { |
||
| 43 | $this->stagedExceptions[$commandName] = $exception ?: new S3Exception($commandName, new Command($commandName)); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function throw500ExceptionWhenExecutingCommand(string $commandName): void |
||
| 47 | { |
||
| 48 | $response = new Response(500); |
||
| 49 | $exception = new S3Exception($commandName, new Command($commandName), compact('response')); |
||
| 50 | |||
| 51 | $this->throwExceptionWhenExecutingCommand($commandName, $exception); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function execute(CommandInterface $command) |
||
| 55 | { |
||
| 56 | return $this->executeAsync($command)->wait(); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function getCommand($name, array $args = []) |
||
| 60 | { |
||
| 61 | return $this->actualClient->getCommand($name, $args); |
||
| 62 | } |
||
| 63 | |||
| 64 | public function getHandlerList() |
||
| 65 | { |
||
| 66 | return $this->actualClient->getHandlerList(); |
||
| 67 | } |
||
| 68 | |||
| 69 | public function getIterator($name, array $args = []) |
||
| 70 | { |
||
| 71 | return $this->actualClient->getIterator($name, $args); |
||
| 72 | } |
||
| 73 | |||
| 74 | public function __call($name, array $arguments) |
||
| 75 | { |
||
| 76 | return $this->actualClient->__call($name, $arguments); |
||
| 77 | } |
||
| 78 | |||
| 79 | public function executeAsync(CommandInterface $command) |
||
| 80 | { |
||
| 81 | if (array_key_exists($name = $command->getName(), $this->stagedExceptions)) { |
||
| 82 | $exception = $this->stagedExceptions[$name]; |
||
| 83 | unset($this->stagedExceptions[$name]); |
||
| 84 | throw $exception; |
||
| 85 | } |
||
| 86 | |||
| 87 | return $this->actualClient->executeAsync($command); |
||
| 88 | } |
||
| 89 | |||
| 90 | public function getCredentials() |
||
| 91 | { |
||
| 92 | return $this->actualClient->getCredentials(); |
||
| 93 | } |
||
| 94 | |||
| 95 | public function getRegion() |
||
| 96 | { |
||
| 97 | return $this->actualClient->getRegion(); |
||
| 98 | } |
||
| 99 | |||
| 100 | public function getEndpoint() |
||
| 101 | { |
||
| 102 | return $this->actualClient->getEndpoint(); |
||
| 103 | } |
||
| 104 | |||
| 105 | public function getApi() |
||
| 106 | { |
||
| 107 | return $this->actualClient->getApi(); |
||
| 108 | } |
||
| 109 | |||
| 110 | public function getConfig($option = null) |
||
| 111 | { |
||
| 112 | return $this->actualClient->getConfig($option); |
||
| 113 | } |
||
| 114 | |||
| 115 | public function getPaginator($name, array $args = []) |
||
| 116 | { |
||
| 117 | return $this->actualClient->getPaginator($name, $args); |
||
| 118 | } |
||
| 119 | |||
| 120 | public function waitUntil($name, array $args = []) |
||
| 121 | { |
||
| 122 | $this->actualClient->waitUntil($name, $args); |
||
| 123 | } |
||
| 124 | |||
| 125 | public function getWaiter($name, array $args = []) |
||
| 126 | { |
||
| 127 | return $this->actualClient->getWaiter($name, $args); |
||
| 128 | } |
||
| 129 | |||
| 130 | public function createPresignedRequest(CommandInterface $command, $expires, array $options = []) |
||
| 131 | { |
||
| 132 | return $this->actualClient->createPresignedRequest($command, $expires, $options); |
||
| 133 | } |
||
| 134 | |||
| 135 | public function getObjectUrl($bucket, $key) |
||
| 136 | { |
||
| 137 | return $this->actualClient->getObjectUrl($bucket, $key); |
||
| 138 | } |
||
| 139 | } |
||
| 140 |