Passed
Push — master ( 0b75f0...6b8772 )
by Fernando
17:35
created

BaseController::isLoggerEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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
    /** @var Container */
13
    protected $container;
14
15 59
    public function __construct(Container $container)
16
    {
17 59
        $this->container = $container;
18 59
    }
19
20
    /**
21
     * @param array|object|null $message
22
     */
23 31
    protected function jsonResponse(
24
        Response $response,
25
        string $status,
26
        $message,
27
        int $code
28
    ): Response {
29
        $result = [
30 31
            'code' => $code,
31 31
            'status' => $status,
32 31
            'message' => $message,
33
        ];
34
35 31
        return $response->withJson($result, $code, JSON_PRETTY_PRINT);
36
    }
37
38 1
    protected static function isRedisEnabled(): bool
39
    {
40 1
        return filter_var($_SERVER['REDIS_ENABLED'], FILTER_VALIDATE_BOOLEAN);
41
    }
42
43 1
    protected static function isLoggerEnabled(): bool
44
    {
45 1
        return filter_var($_SERVER['LOGS_ENABLED'], FILTER_VALIDATE_BOOLEAN);
46
    }
47
}
48