SendSimpleResult::getErrorMessageByErrorCode()   B
last analyzed

Complexity

Conditions 7
Paths 7

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 8.8333
c 0
b 0
f 0
cc 7
nc 7
nop 1
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