DownloadFileResult   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A processResponse() 0 3 1
A getData() 0 3 1
A getErrorMessageByErrorCode() 0 12 4
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
class DownloadFileResult extends Result {
11
	/**
12
	 * @var string
13
	 */
14
	private $data;
15
16
	/**
17
	 * @param string $data
18
	 */
19
	protected function processResponse($data) {
20
		$this->data = $data;
21
	}
22
23
	/**
24
	 * the generated blob id
25
	 *
26
	 * @return string
27
	 */
28
	public function getData() {
29
		return $this->data;
30
	}
31
32
	/**
33
	 * @param int $httpCode
34
	 * @return string
35
	 */
36
	protected function getErrorMessageByErrorCode($httpCode) {
37
		switch($httpCode) {
38
			case 401:
39
				return 'API identity or secret incorrect';
40
			case 404:
41
				return 'Invalid blob id';
42
			case 500:
43
				return 'A temporary internal server error has occurred';
44
			default:
45
				return 'Unknown error';
46
		}
47
	}
48
}
49
50