Failed Conditions
Pull Request — master (#10)
by Maximo
03:05
created

ResponseTrait::halt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 3
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style introduced by
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Traits;
6
7
use Gewaer\Http\Response;
8
use Phalcon\Mvc\Micro;
9
10
/**
11
 * Trait ResponseTrait
12
 *
13
 * @package Gewaer\Traits
14
 */
15
trait ResponseTrait
16
{
17
    /**
18
     * Halt execution after setting the message in the response
19
     *
20
     * @param Micro  $api
21
     * @param int    $status
22
     * @param string $message
23
     *
24
     * @return mixed
25
     */
26 1
    protected function halt(Micro $api, int $status, string $message)
27
    {
28 1
        $apiResponse = new Response();
29
30
        $apiResponse
31 1
            ->setPayloadError($message)
32 1
            ->setStatusCode($status)
33 1
            ->send();
34
35 1
        $api->stop();
36 1
    }
37
}
38