1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Abacaphiliac\AwsSdk\ClaimCheck\Sns; |
4
|
|
|
|
5
|
|
|
use Abacaphiliac\AwsSdk\ClaimCheck\ClaimCheckFactory; |
6
|
|
|
use Abacaphiliac\AwsSdk\ClaimCheck\ClaimCheckFactoryInterface; |
7
|
|
|
use Abacaphiliac\AwsSdk\ClaimCheck\Exception\ExceptionInterface; |
8
|
|
|
use Abacaphiliac\AwsSdk\ClaimCheck\Exception\InvalidArgumentException; |
9
|
|
|
use Abacaphiliac\AwsSdk\ClaimCheck\Serializer\ClaimCheckJsonSerializer; |
10
|
|
|
use Abacaphiliac\AwsSdk\ClaimCheck\Serializer\ClaimCheckSerializerChain; |
11
|
|
|
use Abacaphiliac\AwsSdk\ClaimCheck\Serializer\ClaimCheckSerializerInterface; |
12
|
|
|
use Abacaphiliac\AwsSdk\ClaimCheck\Serializer\JsonSnsMessageSerializer; |
13
|
|
|
use Aws\S3\S3Client; |
14
|
|
|
|
15
|
|
|
class SnsExtendedClientConfiguration |
16
|
|
|
{ |
17
|
|
|
/** @var S3Client */ |
18
|
|
|
private $s3Client; |
19
|
|
|
|
20
|
|
|
/** @var string */ |
21
|
|
|
private $s3BucketName; |
22
|
|
|
|
23
|
|
|
/** @var ClaimCheckFactoryInterface */ |
24
|
|
|
private $claimCheckFactory; |
25
|
|
|
|
26
|
|
|
/** @var ClaimCheckSerializerInterface */ |
27
|
|
|
private $claimCheckSerializer; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* ExtendedClientConfiguration constructor. |
31
|
|
|
* @param S3Client $s3Client |
32
|
|
|
* @param string $s3BucketName |
33
|
|
|
* @throws ExceptionInterface |
34
|
|
|
*/ |
35
|
7 |
View Code Duplication |
public function __construct(S3Client $s3Client, $s3BucketName) |
|
|
|
|
36
|
|
|
{ |
37
|
7 |
|
if (!$s3BucketName) { |
38
|
2 |
|
throw new InvalidArgumentException('S3 Bucket Name is required and cannot be empty.'); |
39
|
|
|
} |
40
|
|
|
|
41
|
7 |
|
$this->s3Client = $s3Client; |
42
|
7 |
|
$this->s3BucketName = $s3BucketName; |
43
|
7 |
|
$this->claimCheckFactory = new ClaimCheckFactory($s3BucketName); |
44
|
7 |
|
$this->claimCheckSerializer = new ClaimCheckSerializerChain(array( |
45
|
7 |
|
new ClaimCheckJsonSerializer(), |
46
|
7 |
|
new JsonSnsMessageSerializer(), |
47
|
7 |
|
)); |
48
|
7 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return S3Client |
52
|
|
|
*/ |
53
|
2 |
|
public function getS3Client() |
54
|
|
|
{ |
55
|
2 |
|
return $this->s3Client; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param S3Client $s3Client |
60
|
|
|
*/ |
61
|
1 |
|
public function setS3Client($s3Client) |
62
|
|
|
{ |
63
|
1 |
|
$this->s3Client = $s3Client; |
64
|
1 |
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
2 |
|
public function getS3BucketName() |
70
|
|
|
{ |
71
|
2 |
|
return $this->s3BucketName; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param string $s3BucketName |
76
|
|
|
*/ |
77
|
1 |
|
public function setS3BucketName($s3BucketName) |
78
|
|
|
{ |
79
|
1 |
|
$this->s3BucketName = $s3BucketName; |
80
|
1 |
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return ClaimCheckFactoryInterface |
84
|
|
|
*/ |
85
|
2 |
|
public function getClaimCheckFactory() |
86
|
|
|
{ |
87
|
2 |
|
return $this->claimCheckFactory; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param ClaimCheckFactoryInterface $claimCheckFactory |
92
|
|
|
*/ |
93
|
1 |
|
public function setClaimCheckFactory($claimCheckFactory) |
94
|
|
|
{ |
95
|
1 |
|
$this->claimCheckFactory = $claimCheckFactory; |
96
|
1 |
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return ClaimCheckSerializerInterface |
100
|
|
|
*/ |
101
|
2 |
|
public function getClaimCheckSerializer() |
102
|
|
|
{ |
103
|
2 |
|
return $this->claimCheckSerializer; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param ClaimCheckSerializerInterface $claimCheckSerializer |
108
|
|
|
*/ |
109
|
1 |
|
public function setClaimCheckSerializer(ClaimCheckSerializerInterface $claimCheckSerializer) |
110
|
|
|
{ |
111
|
1 |
|
$this->claimCheckSerializer = $claimCheckSerializer; |
112
|
1 |
|
} |
113
|
|
|
} |
114
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.