SendE2EResult   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 38
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A processResponse() 3 3 1
A getMessageId() 3 3 1
A getErrorMessageByErrorCode() 16 16 6

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
 * @author Threema GmbH
4
 * @copyright Copyright (c) 2015-2016 Threema GmbH
5
 */
6
7
8
namespace Threema\MsgApi\Commands\Results;
9
10 View Code Duplication
class SendE2EResult extends Result {
0 ignored issues
show
Duplication introduced by
This class 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...
11
	/**
12
	 * @var string
13
	 */
14
	private $messageId;
15
16
	/**
17
	 * @param string $response
18
	 */
19
	protected function processResponse($response) {
20
		$this->messageId = (string)$response;
21
	}
22
23
	public function getMessageId() {
24
		return $this->messageId;
25
	}
26
27
	/**
28
	 * @param int $httpCode
29
	 * @return string
30
	 */
31
	protected function getErrorMessageByErrorCode($httpCode) {
32
		switch($httpCode) {
33
			case 400:
34
				return 'The recipient identity is invalid or the account is not set up for E2E mode';
35
			case 401:
36
				return 'API identity or secret incorrect';
37
			case 402:
38
				return 'No credits remain';
39
			case 413:
40
				return 'Message is too long';
41
			case 500:
42
				return 'A temporary internal server error has occurred';
43
			default:
44
				return 'Unknown error';
45
		}
46
	}
47
}
48