Completed
Push — DAVclient ( 8808e7...202085 )
by Raimund
03:25
created

Response   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateResponse() 0 17 2
1
<?php
2
3
namespace OCA\Tasks\Controller;
4
5
use \Closure;
6
use \OCP\AppFramework\Http\JSONResponse;
7
8
trait Response {
9
10
	protected function generateResponse (Closure $callback) {
11
		try {
12
			$message = [
13
				'status' => 'success',
14
				'data' => $callback(),
15
				'message' => null
16
			];
17
18
		} catch(\Exception $e) {
19
			$message = [
20
				'status' => 'error',
21
				'data' => null,
22
				'message' => $e->getMessage()
23
			];
24
		}
25
		return new JSONResponse($message);
26
	}
27
28
}