Conditions | 1 |
Paths | 1 |
Total Lines | 132 |
Code Lines | 85 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
20 | protected function setUp() |
||
21 | { |
||
22 | // prepare sqs response collections - begin |
||
23 | $createQueueResult = new Collection([ |
||
24 | 'MessageId' => 'createQueueResultId', |
||
25 | 'QueueUrl' => 'http://queue.url/path/', |
||
26 | ]); |
||
27 | |||
28 | $sendMessageResult = new Collection([ |
||
29 | 'MessageId' => 'sendMessageResultId', |
||
30 | ]); |
||
31 | |||
32 | $getQueueAttributesResult1 = new Collection([ |
||
33 | 'MessageId' => 'getQueueAttributesResult1Id', |
||
34 | 'Attributes' => [ |
||
35 | 'ApproximateNumberOfMessages' => 1, |
||
36 | ], |
||
37 | ]); |
||
38 | $getQueueAttributesResult2 = new Collection([ |
||
39 | 'MessageId' => 'getQueueAttributesResult2Id', |
||
40 | 'Attributes' => [ |
||
41 | 'ApproximateNumberOfMessages' => 0, |
||
42 | ], |
||
43 | ]); |
||
44 | |||
45 | $receiveMessageResult1 = new Collection([ |
||
46 | 'Messages' => [ |
||
47 | [ |
||
48 | 'MessageId' => 'receiveMessageResult1Id', |
||
49 | 'ReceiptHandle' => 'receiveMessageResult1Handle', |
||
50 | 'Body' => json_encode(FixtureHelper::getMailMessage()), |
||
51 | ], |
||
52 | ], |
||
53 | ]); |
||
54 | $receiveMessageResult2 = new Collection([ |
||
55 | // no message(s) returned by Amazon SQS |
||
56 | ]); |
||
57 | // prepare sqs response collections - end |
||
58 | |||
59 | // ------------------------------------------------------------ |
||
60 | |||
61 | // prepare queue store 1 - begin |
||
62 | /** @var SqsClient $sqsClient1 */ |
||
63 | $sqsClient1 = Mockery::mock('\Aws\Sqs\SqsClient') |
||
|
|||
64 | ->shouldReceive('createQueue') |
||
65 | ->with(Mockery::mustBe([ |
||
66 | 'QueueName' => 'testing_queue_1', |
||
67 | ])) |
||
68 | ->andReturn($createQueueResult) |
||
69 | ->shouldReceive('sendMessage') |
||
70 | ->with(Mockery::mustBe([ |
||
71 | 'QueueUrl' => 'http://queue.url/path/', |
||
72 | 'MessageBody' => json_encode(FixtureHelper::getMailMessage()), |
||
73 | 'DelaySeconds' => null, |
||
74 | ])) |
||
75 | ->andReturn($sendMessageResult) |
||
76 | ->shouldReceive('getQueueAttributes') |
||
77 | ->with(Mockery::mustBe([ |
||
78 | 'QueueUrl' => 'http://queue.url/path/', |
||
79 | 'AttributeNames' => ['ApproximateNumberOfMessages'], |
||
80 | ])) |
||
81 | ->andReturn($getQueueAttributesResult1, $getQueueAttributesResult2) |
||
82 | ->shouldReceive('receiveMessage') |
||
83 | ->with(Mockery::mustBe([ |
||
84 | 'QueueUrl' => 'http://queue.url/path/', |
||
85 | ])) |
||
86 | ->andReturn($receiveMessageResult1, $receiveMessageResult2) |
||
87 | ->shouldReceive('deleteMessage') |
||
88 | ->with(Mockery::mustBe([ |
||
89 | 'QueueUrl' => 'http://queue.url/path/', |
||
90 | 'ReceiptHandle' => 'receiveMessageResult1Handle', |
||
91 | ])) |
||
92 | ->getMock(); |
||
93 | |||
94 | /** @var SqsQueueStoreConnection $sqsQueueStoreConnection1 */ |
||
95 | $sqsQueueStoreConnection1 = Mockery::mock('\Da\Mailer\Queue\Backend\Sqs\SqsQueueStoreConnection') |
||
96 | ->shouldReceive('connect') |
||
97 | ->andReturnSelf() |
||
98 | ->shouldReceive('getInstance') |
||
99 | ->andReturn($sqsClient1) |
||
100 | ->getMock(); |
||
101 | |||
102 | $this->sqsQueueStore1 = new SqsQueueStoreAdapter($sqsQueueStoreConnection1, 'testing_queue_1'); |
||
103 | // prepare queue store 1 - end |
||
104 | |||
105 | // ------------------------------------------------------------ |
||
106 | |||
107 | // prepare queue store 2 - begin |
||
108 | /** @var SqsClient $sqsClient1 */ |
||
109 | $sqsClient2 = Mockery::mock('\Aws\Sqs\SqsClient') |
||
110 | ->shouldReceive('createQueue') |
||
111 | ->with(Mockery::mustBe([ |
||
112 | 'QueueName' => 'testing_queue_2', |
||
113 | ])) |
||
114 | ->andReturn($createQueueResult) |
||
115 | ->shouldReceive('sendMessage') |
||
116 | ->with(Mockery::mustBe([ |
||
117 | 'QueueUrl' => 'http://queue.url/path/', |
||
118 | 'MessageBody' => json_encode(FixtureHelper::getMailMessage()), |
||
119 | 'DelaySeconds' => null, |
||
120 | ])) |
||
121 | ->andReturn($sendMessageResult) |
||
122 | ->shouldReceive('getQueueAttributes') |
||
123 | ->with(Mockery::mustBe([ |
||
124 | 'QueueUrl' => 'http://queue.url/path/', |
||
125 | 'AttributeNames' => ['ApproximateNumberOfMessages'], |
||
126 | ])) |
||
127 | ->andReturn($getQueueAttributesResult1, $getQueueAttributesResult2, $getQueueAttributesResult1) |
||
128 | ->shouldReceive('receiveMessage') |
||
129 | ->with(Mockery::mustBe([ |
||
130 | 'QueueUrl' => 'http://queue.url/path/', |
||
131 | ])) |
||
132 | ->andReturn($receiveMessageResult1, $receiveMessageResult2) |
||
133 | ->shouldReceive('changeMessageVisibility') |
||
134 | ->with(Mockery::mustBe([ |
||
135 | 'QueueUrl' => 'http://queue.url/path/', |
||
136 | 'ReceiptHandle' => 'receiveMessageResult1Handle', |
||
137 | 'VisibilityTimeout' => 5, |
||
138 | ])) |
||
139 | ->getMock(); |
||
140 | |||
141 | /** @var SqsQueueStoreConnection $sqsQueueStoreConnection1 */ |
||
142 | $sqsQueueStoreConnection1 = Mockery::mock('\Da\Mailer\Queue\Backend\Sqs\SqsQueueStoreConnection') |
||
143 | ->shouldReceive('connect') |
||
144 | ->andReturnSelf() |
||
145 | ->shouldReceive('getInstance') |
||
146 | ->andReturn($sqsClient2) |
||
147 | ->getMock(); |
||
148 | |||
149 | $this->sqsQueueStore2 = new SqsQueueStoreAdapter($sqsQueueStoreConnection1, 'testing_queue_2'); |
||
150 | // prepare queue store 2 - end |
||
151 | } |
||
152 | |||
237 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.