BaseController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 2
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller;
6
7
use Slim\Container;
8
use Slim\Http\Response;
9
10
abstract class BaseController
11
{
12
    public function __construct(protected Container $container)
13
    {
14 59
    }
15
16 59
    /**
17 59
     * @param array|object|null $message
18
     */
19
    protected function jsonResponse(
20
        Response $response,
21
        string $status,
22 31
        $message,
23
        int $code
24
    ): Response {
25
        $result = [
26
            'code' => $code,
27
            'status' => $status,
28
            'message' => $message,
29 31
        ];
30 31
31 31
        return $response->withJson($result, $code, JSON_PRETTY_PRINT);
32
    }
33
34 31
    protected static function isRedisEnabled(): bool
35
    {
36
        return filter_var($_SERVER['REDIS_ENABLED'], FILTER_VALIDATE_BOOLEAN);
37 1
    }
38
39 1
    protected static function isLoggerEnabled(): bool
40
    {
41
        return filter_var($_SERVER['LOGS_ENABLED'], FILTER_VALIDATE_BOOLEAN);
42 1
    }
43
}
44