/** * @param ClaimCheck $claimCheck * @return string * @throws ExceptionInterface */ private function fetchClaimCheckFromS3(ClaimCheck $claimCheck) { $s3Client = $this->configuration->getS3Client(); $result = $s3Client->getObject(['Bucket' => $claimCheck->getS3BucketName(), 'Key' => $claimCheck->getS3Key()]); $body = $result->get('Body'); // Unpack the message. if ($body instanceof StreamInterface) { try { return $body->getContents(); } catch (\RuntimeException $e) { throw new RuntimeException($e->getMessage(), 0, $e); } } return $body; }
/** * @param ClaimCheck $claimCheck * @return string * @throws ExceptionInterface */ public function serialize(ClaimCheck $claimCheck) { return Json::encode(array('s3BucketName' => $claimCheck->getS3BucketName(), 's3Key' => $claimCheck->getS3Key())); }
public function testGetKey() { $sut = new ClaimCheck('MyBucket', $expected = 'MyKey'); self::assertEquals($expected, $sut->getS3Key()); }