SendSimpleResult   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 43
loc 43
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
B getErrorMessageByErrorCode() 18 18 7

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 SendSimpleResult 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
	/**
24
	 * @return string
25
	 */
26
	public function getMessageId() {
27
		return $this->messageId;
28
	}
29
30
	/**
31
	 * @param int $httpCode
32
	 * @return string
33
	 */
34
	protected function getErrorMessageByErrorCode($httpCode) {
35
		switch($httpCode) {
36
			case 400:
37
				return 'The recipient identity is invalid or the account is not set up for simple mode';
38
			case 401:
39
				return 'API identity or secret incorrect';
40
			case 402:
41
				return 'No credits remain';
42
			case 404:
43
				return 'Phone or email could not be found';
44
			case 413:
45
				return 'Message is too long';
46
			case 500:
47
				return 'A temporary internal server error has occurred';
48
			default:
49
				return 'Unknown error';
50
		}
51
	}
52
}
53