Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Application
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 initialize
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * @package Zmsstatistic
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsstatistic;
9
10use BO\Slim\Helper\ModuleLoggerInitializer;
11use BO\Zmsclient\Http;
12use Psr\SimpleCache\CacheInterface;
13
14define(
15    'ZMS_STATISTIC_SESSION_DURATION',
16    (int) ((($value = getenv('ZMS_STATISTIC_SESSION_DURATION')) !== false && $value !== '') ? $value : 36000)
17);
18
19if (($token = getenv('ZMS_CONFIG_SECURE_TOKEN')) === false || $token === '') {
20    throw new \RuntimeException('ZMS_CONFIG_SECURE_TOKEN environment variable must be set');
21}
22
23define('ZMS_CONFIG_SECURE_TOKEN', getenv('ZMS_CONFIG_SECURE_TOKEN'));
24
25if (!defined('ZMS_STATISTIC_TWIG_CACHE')) {
26    $value = getenv('ZMS_STATISTIC_TWIG_CACHE');
27    if ($value === 'false') {
28        define('ZMS_STATISTIC_TWIG_CACHE', false);
29    } elseif ($value === false || $value === '') {
30        define('ZMS_STATISTIC_TWIG_CACHE', '/cache/');
31    } else {
32        define('ZMS_STATISTIC_TWIG_CACHE', $value);
33    }
34}
35
36class Application extends \BO\Slim\Application
37{
38    /**
39     * Name of the application
40     *
41     */
42    const string IDENTIFIER = 'zms';
43
44    const string MODULE_NAME = 'zmsstatistic';
45
46    public static ?CacheInterface $cache = null;
47
48    const bool DEBUG = false;
49
50    const mixed TWIG_CACHE = ZMS_STATISTIC_TWIG_CACHE;
51
52    const int SESSION_DURATION = ZMS_STATISTIC_SESSION_DURATION;
53
54    /** @var string */
55    public static $includeUrl = '/terminvereinbarung/statistic';
56    /**
57     * language preferences
58     */
59    public static string $locale = 'de';
60    /** @var array */
61    public static $supportedLanguages = array(
62        // Default language
63        'de' => array(
64            'name'    => 'Deutsch',
65            'locale'  => 'de_DE',
66            'default' => true,
67        ),
68        // Other languages
69        'en' => array(
70            'name'    => 'English',
71            'locale'  => 'en_GB',
72        )
73    );
74
75    /**
76     * image preferences
77     */
78
79    /** @var bool */
80    public static $isImageAllowed = false;
81
82    /*
83     * -----------------------------------------------------------------------
84     * ZMS API access
85     */
86    public static ?Http $http = null;
87
88    public static array $http_curl_config = array();
89
90    const int JSON_COMPRESS_LEVEL = 1;
91
92    /**
93    * config preferences
94    */
95    const string CONFIG_SECURE_TOKEN = ZMS_CONFIG_SECURE_TOKEN;
96
97    /**
98     * HTTP url for api
99     */
100    const string HTTP_BASE_URL = 'http://user:pass@host.tdl';
101
102    public static function initialize(): void
103    {
104        ModuleLoggerInitializer::configure('ZMS_STATISTIC');
105        self::$cache = ModuleLoggerInitializer::tryInitializeCache();
106    }
107}
108
109Application::initialize();