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

library/Traits/ResponseTrait.php (1 issue)

1
<?php
0 ignored issues
show
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