forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.ilRuntime.php
More file actions
142 lines (128 loc) · 2.04 KB
/
class.ilRuntime.php
File metadata and controls
142 lines (128 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
/**
* Class ilRuntime
* @author Michael Jansen <mjansen@databay.de>
* @package Services/Environment
*/
final class ilRuntime
{
/**
* @var self
*/
private static $instance = null;
/**
* The runtime is a constant state during one request, so please use the public static getInstance() to instantiate the runtime
*/
private function __construct(){}
/**
* @return self
*/
public static function getInstance()
{
if(self::$instance === null)
{
self::$instance = new self();
}
return self::$instance;
}
/**
* Returns true when the runtime used is HHVM.
* @return bool
*/
public function isHHVM()
{
return defined('HHVM_VERSION');
}
/**
* Returns true when the runtime used is PHP.
* @return bool
*/
public function isPHP()
{
return !$this->isHHVM();
}
/**
* @return bool
*/
public function isFPM() {
return (php_sapi_name() == 'fpm-fcgi');
}
/**
* @return string
*/
public function getVersion()
{
if($this->isHHVM())
{
return HHVM_VERSION;
}
else
{
return PHP_VERSION;
}
}
/**
* @return string
*/
public function getName()
{
if($this->isHHVM())
{
return 'HHVM';
}
else
{
return 'PHP';
}
}
/**
* A string representation of the runtime
*/
public function __toString()
{
return $this->getName() . ' ' . $this->getVersion();
}
/**
* @return int
*/
public function getReportedErrorLevels()
{
if($this->isHHVM())
{
return ini_get('hhvm.log.runtime_error_reporting_level');
}
else
{
return ini_get('error_reporting');
}
}
/**
* @return boolean
*/
public function shouldLogErrors()
{
if($this->isHHVM())
{
return (bool)ini_get('hhvm.log.use_log_file');
}
else
{
return (bool)ini_get('log_errors');
}
}
/**
* @return boolean
*/
public function shouldDisplayErrors()
{
if($this->isHHVM())
{
return (bool)ini_get('hhvm.debug.server_error_message');
}
else
{
return (bool)ini_get('display_errors');
}
}
}