JSONHttpError   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A error() 0 3 1
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Bernhard Posselt <[email protected]>
9
 * @copyright Bernhard Posselt 2014
10
 */
11
12
namespace OCA\News\Controller;
13
14
use \OCP\AppFramework\Http\JSONResponse;
15
16
17
trait JSONHttpError {
18
19
20
    /**
21
     * @param \Exception $exception the message that is returned taken from the
22
     * exception
23
     * @param int $code the http error code
24
     * @return \OCP\AppFramework\Http\JSONResponse
25
     */
26
    public function error(\Exception $exception, $code) {
27
        return new JSONResponse(['message' => $exception->getMessage()], $code);
28
    }
29
30
31
}