1 | <?php |
||
21 | class Helper |
||
22 | { |
||
23 | /** |
||
24 | * Name of username PHP constant or environmental variables |
||
25 | * |
||
26 | * @const REPORTING_CLOUD_USERNAME |
||
27 | */ |
||
28 | const USERNAME = 'REPORTING_CLOUD_USERNAME'; |
||
29 | |||
30 | /** |
||
31 | * Name of password PHP constant or environmental variables |
||
32 | * |
||
33 | * @const REPORTING_CLOUD_PASSWORD |
||
34 | */ |
||
35 | const PASSWORD = 'REPORTING_CLOUD_PASSWORD'; |
||
36 | |||
37 | /** |
||
38 | * Return error message explaining how to configure PHP constant or environmental variables |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | public static function errorMessage() |
||
73 | |||
74 | /** |
||
75 | * Return the ReportingCloud username |
||
76 | * |
||
77 | * @return null|string |
||
78 | */ |
||
79 | public static function username() |
||
85 | |||
86 | /** |
||
87 | * Return the ReportingCloud password |
||
88 | * |
||
89 | * @return null|string |
||
90 | */ |
||
91 | public static function password() |
||
97 | |||
98 | /** |
||
99 | * Check credentials have been define in environment variables, otherwise exit with error code 1 |
||
100 | */ |
||
101 | public static function checkCredentials() |
||
110 | |||
111 | /** |
||
112 | * Return the value of the PHP constant or environmental variable |
||
113 | * |
||
114 | * @param string $variable Variable |
||
115 | * |
||
116 | * @return null|string |
||
117 | */ |
||
118 | protected static function variable($variable) |
||
136 | |||
137 | } |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.