SqsExtendedClientConfiguration   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 118
Duplicated Lines 11.86 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 12
c 1
b 0
f 1
lcom 0
cbo 5
dl 14
loc 118
rs 10
ccs 36
cts 36
cp 1

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 14 14 2
A getS3Client() 0 4 1
A setS3Client() 0 4 1
A getS3BucketName() 0 4 1
A setS3BucketName() 0 4 1
A getClaimCheckFactory() 0 4 1
A setClaimCheckFactory() 0 4 1
A getClaimCheckSerializer() 0 4 1
A setClaimCheckSerializer() 0 4 1
A getDeleteFromS3() 0 4 1
A setDeleteFromS3() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Abacaphiliac\AwsSdk\ClaimCheck\Sqs;
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 SqsExtendedClientConfiguration
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
    /** @var  bool */
30
    private $deleteFromS3 = true;
31
32
    /**
33
     * ExtendedClientConfiguration constructor.
34
     * @param S3Client $s3Client
35
     * @param string $s3BucketName
36
     * @throws ExceptionInterface
37
     */
38 12 View Code Duplication
    public function __construct(S3Client $s3Client, $s3BucketName)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
39
    {
40 12
        if (!$s3BucketName) {
41 2
            throw new InvalidArgumentException('S3 Bucket Name is required and cannot be empty.');
42
        }
43
        
44 12
        $this->s3Client = $s3Client;
45 12
        $this->s3BucketName = $s3BucketName;
46 12
        $this->claimCheckFactory = new ClaimCheckFactory($s3BucketName);
47 12
        $this->claimCheckSerializer = new ClaimCheckSerializerChain(array(
48 12
            new ClaimCheckJsonSerializer(),
49 12
            new JsonSnsMessageSerializer(),
50 12
        ));
51 12
    }
52
53
    /**
54
     * @return S3Client
55
     */
56 5
    public function getS3Client()
57
    {
58 5
        return $this->s3Client;
59
    }
60
61
    /**
62
     * @param S3Client $s3Client
63
     */
64 1
    public function setS3Client($s3Client)
65
    {
66 1
        $this->s3Client = $s3Client;
67 1
    }
68
69
    /**
70
     * @return string
71
     */
72 2
    public function getS3BucketName()
73
    {
74 2
        return $this->s3BucketName;
75
    }
76
77
    /**
78
     * @param string $s3BucketName
79
     */
80 1
    public function setS3BucketName($s3BucketName)
81
    {
82 1
        $this->s3BucketName = $s3BucketName;
83 1
    }
84
85
    /**
86
     * @return ClaimCheckFactoryInterface
87
     */
88 2
    public function getClaimCheckFactory()
89
    {
90 2
        return $this->claimCheckFactory;
91
    }
92
93
    /**
94
     * @param ClaimCheckFactoryInterface $claimCheckFactory
95
     */
96 1
    public function setClaimCheckFactory($claimCheckFactory)
97
    {
98 1
        $this->claimCheckFactory = $claimCheckFactory;
99 1
    }
100
101
    /**
102
     * @return ClaimCheckSerializerInterface
103
     */
104 5
    public function getClaimCheckSerializer()
105
    {
106 5
        return $this->claimCheckSerializer;
107
    }
108
109
    /**
110
     * @param ClaimCheckSerializerInterface $claimCheckSerializer
111
     */
112 1
    public function setClaimCheckSerializer(ClaimCheckSerializerInterface $claimCheckSerializer)
113
    {
114 1
        $this->claimCheckSerializer = $claimCheckSerializer;
115 1
    }
116
117
    /**
118
     * @return boolean
119
     */
120 3
    public function getDeleteFromS3()
121
    {
122 3
        return $this->deleteFromS3;
123
    }
124
125
    /**
126
     * @param boolean $deleteFromS3
127
     */
128 1
    public function setDeleteFromS3($deleteFromS3)
129
    {
130 1
        $this->deleteFromS3 = $deleteFromS3;
131 1
    }
132
}
133