Test Failed
Push — master ( 1f2e19...0342a7 )
by Pavel
01:42
created

RestResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A noContent() 0 3 1
A exception() 0 3 1
A notFound() 0 3 1
1
<?php namespace Pz\Doctrine\Rest;
2
3
use Symfony\Component\HttpFoundation\JsonResponse;
4
5
class RestResponse extends JsonResponse
6
{
7
    /**
8
     * @param string $message
9
     *
10
     * @return static
11
     */
12
    public static function notFound($message)
13
    {
14
        return static::create($message, static::HTTP_NOT_FOUND);
15
    }
16
17
    /**
18
     * @return static
19
     */
20 1
    public static function noContent()
21
    {
22 1
        return static::create(null, static::HTTP_NO_CONTENT);
23
    }
24
25
    /**
26
     * @param \Error|\Exception|RestException $exception
27
     *
28
     * @return RestResponse
29
     * @throws \Error|\Exception|RestException
30
     */
31 1
    public static function exception(RestException $exception)
32
    {
33 1
        return RestResponse::create(['errors' => $exception->errors()], $exception->httpStatus());
34
    }
35
}
36