ResponseTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 21
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A halt() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Traits;
6
7
use Canvas\Http\Response;
8
use Phalcon\Mvc\Micro;
0 ignored issues
show
Bug introduced by
The type Phalcon\Mvc\Micro was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use function Canvas\Core\isSwooleServer;
10
11
/**
12
 * Trait ResponseTrait
13
 *
14
 * @package Canvas\Traits
15
 */
16
trait ResponseTrait
17
{
18
    /**
19
     * Halt execution after setting the message in the response
20
     *
21
     * @param Micro  $api
22
     * @param int    $status
23
     * @param string $message
24
     *
25
     * @return mixed
26
     */
27
    protected function halt(Micro $api, int $status, string $message)
28
    {
29
        $apiResponse = !isSwooleServer() ? new Response() : $this->response;
30
31
        $apiResponse
32
            ->setPayloadError($message)
33
            ->setStatusCode($status)
34
            ->send();
35
36
        $api->stop();
37
    }
38
}
39