Code Duplication    Length = 38-43 lines in 2 locations

source/Threema/MsgApi/Commands/Results/SendE2EResult.php 1 location

@@ 10-47 (lines=38) @@
7
8
namespace Threema\MsgApi\Commands\Results;
9
10
class SendE2EResult extends Result {
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

source/Threema/MsgApi/Commands/Results/SendSimpleResult.php 1 location

@@ 10-52 (lines=43) @@
7
8
namespace Threema\MsgApi\Commands\Results;
9
10
class SendSimpleResult extends Result {
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