Conditions | 1 |
Paths | 1 |
Total Lines | 124 |
Code Lines | 78 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 2 | 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 | |||
33 | $getQueueAttributesResult1 = new Collection([ |
||
34 | 'MessageId' => 'getQueueAttributesResult1Id', |
||
35 | 'Attributes' => [ |
||
36 | 'ApproximateNumberOfMessages' => 1, |
||
37 | ], |
||
38 | ]); |
||
39 | $getQueueAttributesResult2 = new Collection([ |
||
40 | 'MessageId' => 'getQueueAttributesResult2Id', |
||
41 | 'Attributes' => [ |
||
42 | 'ApproximateNumberOfMessages' => 0, |
||
43 | ], |
||
44 | ]); |
||
45 | |||
46 | $receiveMessageResult1 = new Collection([ |
||
47 | 'Messages' => [ |
||
48 | [ |
||
49 | 'MessageId' => 'receiveMessageResult1Id', |
||
50 | 'ReceiptHandle' => 'receiveMessageResult1Handle', |
||
51 | 'Body' => json_encode(FixtureHelper::getMailMessage()), |
||
52 | 'Attempt' => 1 |
||
53 | ], |
||
54 | ], |
||
55 | ]); |
||
56 | $receiveMessageResult2 = new Collection([ |
||
57 | // no message(s) returned by Amazon SQS |
||
58 | ]); |
||
59 | // prepare sqs response collections - end |
||
60 | |||
61 | // ------------------------------------------------------------ |
||
62 | |||
63 | // prepare queue store 1 - begin |
||
64 | /** @var SqsClient $sqsClient1 */ |
||
65 | $sqsClient1 = Mockery::mock('\Aws\Sqs\SqsClient') |
||
|
|||
66 | ->shouldReceive('createQueue') |
||
67 | ->with(Mockery::mustBe([ |
||
68 | 'QueueName' => 'testing_queue_1', |
||
69 | ])) |
||
70 | ->andReturn($createQueueResult) |
||
71 | ->shouldReceive('sendMessage') |
||
72 | ->andReturn($sendMessageResult) |
||
73 | ->shouldReceive('getQueueAttributes') |
||
74 | ->with(Mockery::mustBe([ |
||
75 | 'QueueUrl' => 'http://queue.url/path/', |
||
76 | 'AttributeNames' => ['ApproximateNumberOfMessages'], |
||
77 | ])) |
||
78 | ->andReturn($getQueueAttributesResult1, $getQueueAttributesResult2) |
||
79 | ->shouldReceive('receiveMessage') |
||
80 | ->with(Mockery::mustBe([ |
||
81 | 'QueueUrl' => 'http://queue.url/path/', |
||
82 | ])) |
||
83 | ->andReturn($receiveMessageResult1, $receiveMessageResult2) |
||
84 | ->shouldReceive('deleteMessage') |
||
85 | ->with(Mockery::mustBe([ |
||
86 | 'QueueUrl' => 'http://queue.url/path/', |
||
87 | 'ReceiptHandle' => 'receiveMessageResult1Handle', |
||
88 | ])) |
||
89 | ->getMock(); |
||
90 | |||
91 | /** @var SqsQueueStoreConnection $sqsQueueStoreConnection1 */ |
||
92 | $sqsQueueStoreConnection1 = Mockery::mock('\Da\Mailer\Queue\Backend\Sqs\SqsQueueStoreConnection') |
||
93 | ->shouldReceive('connect') |
||
94 | ->andReturnSelf() |
||
95 | ->shouldReceive('getInstance') |
||
96 | ->andReturn($sqsClient1) |
||
97 | ->getMock(); |
||
98 | |||
99 | $this->sqsQueueStore1 = new SqsQueueStoreAdapter($sqsQueueStoreConnection1, 'testing_queue_1'); |
||
100 | // prepare queue store 1 - end |
||
101 | |||
102 | // ------------------------------------------------------------ |
||
103 | |||
104 | // prepare queue store 2 - begin |
||
105 | /** @var SqsClient $sqsClient1 */ |
||
106 | $sqsClient2 = Mockery::mock('\Aws\Sqs\SqsClient') |
||
107 | ->shouldReceive('createQueue') |
||
108 | ->with(Mockery::mustBe([ |
||
109 | 'QueueName' => 'testing_queue_2', |
||
110 | ])) |
||
111 | ->andReturn($createQueueResult) |
||
112 | ->shouldReceive('sendMessage') |
||
113 | ->andReturn($sendMessageResult) |
||
114 | ->shouldReceive('getQueueAttributes') |
||
115 | ->with(Mockery::mustBe([ |
||
116 | 'QueueUrl' => 'http://queue.url/path/', |
||
117 | 'AttributeNames' => ['ApproximateNumberOfMessages'], |
||
118 | ])) |
||
119 | ->andReturn($getQueueAttributesResult1, $getQueueAttributesResult2, $getQueueAttributesResult1) |
||
120 | ->shouldReceive('receiveMessage') |
||
121 | ->with(Mockery::mustBe([ |
||
122 | 'QueueUrl' => 'http://queue.url/path/', |
||
123 | ])) |
||
124 | ->andReturn($receiveMessageResult1, $receiveMessageResult2) |
||
125 | ->shouldReceive('changeMessageVisibility') |
||
126 | ->with(Mockery::mustBe([ |
||
127 | 'QueueUrl' => 'http://queue.url/path/', |
||
128 | 'ReceiptHandle' => 'receiveMessageResult1Handle', |
||
129 | 'VisibilityTimeout' => 5, |
||
130 | ])) |
||
131 | ->getMock(); |
||
132 | |||
133 | /** @var SqsQueueStoreConnection $sqsQueueStoreConnection1 */ |
||
134 | $sqsQueueStoreConnection1 = Mockery::mock('\Da\Mailer\Queue\Backend\Sqs\SqsQueueStoreConnection') |
||
135 | ->shouldReceive('connect') |
||
136 | ->andReturnSelf() |
||
137 | ->shouldReceive('getInstance') |
||
138 | ->andReturn($sqsClient2) |
||
139 | ->getMock(); |
||
140 | |||
141 | $this->sqsQueueStore2 = new SqsQueueStoreAdapter($sqsQueueStoreConnection1, 'testing_queue_2'); |
||
142 | // prepare queue store 2 - end |
||
143 | } |
||
144 | |||
229 |
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.