for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Gaufrette\Extras\Resolvable\Resolver;
use Aws\S3\S3Client;
use Gaufrette\Extras\Resolvable\ResolverInterface;
class AwsS3PresignedUrlResolver implements ResolverInterface
{
/** @var S3Client */
private $service;
/** @var string */
private $bucket;
private $baseDir;
/** @var \DateTimeInterface */
private $expiresAt;
public function __construct(S3Client $service, $bucket, $baseDir, \DateTimeInterface $expiresAt)
$this->service = $service;
$this->bucket = $bucket;
$this->baseDir = trim($baseDir, '/');
$this->expiresAt = $expiresAt;
}
/**
* Resolves given object path into presigned request URI.
*
* @param string $path
* @return (string) \Psr\Http\Message\UriInterface
*/
public function resolve($path)
$command = $this->service->getCommand('GetObject', [
'Bucket' => $this->bucket,
'Key' => $this->computePath($path),
]);
return (string) $this->service->createPresignedRequest($command, $this->expiresAt)->getUri();
$this->expiresAt
object<DateTimeInterface>
integer|string|object<DateTime>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
* Appends baseDir to $key.
* @param string $key
* @return string
private function computePath($key)
return ltrim($this->baseDir . '/' . ltrim($key, '/'), '/');
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: