1 | <?php |
||
22 | class Helper |
||
23 | { |
||
24 | /** |
||
25 | * Line length in characters (used to wrap long lines) |
||
26 | */ |
||
27 | const LINE_LENGTH = 80; |
||
28 | |||
29 | /** |
||
30 | * Name of username PHP constant or environmental variables |
||
31 | * |
||
32 | * @const REPORTING_CLOUD_USERNAME |
||
33 | */ |
||
34 | const USERNAME = 'REPORTING_CLOUD_USERNAME'; |
||
35 | |||
36 | /** |
||
37 | * Name of password PHP constant or environmental variables |
||
38 | * |
||
39 | * @const REPORTING_CLOUD_PASSWORD |
||
40 | */ |
||
41 | const PASSWORD = 'REPORTING_CLOUD_PASSWORD'; |
||
42 | |||
43 | /** |
||
44 | * Name of API key PHP constant or environmental variables |
||
45 | * |
||
46 | * @const REPORTING_CLOUD_API_KEY |
||
47 | */ |
||
48 | const API_KEY = 'REPORTING_CLOUD_API_KEY'; |
||
49 | |||
50 | /** |
||
51 | * Check ReportingCloud credentials, which have been defined in environment variables, otherwise terminate script |
||
52 | * execution with error code 1 |
||
53 | */ |
||
54 | public static function checkCredentials() |
||
67 | |||
68 | /** |
||
69 | * Return the ReportingCloud username |
||
70 | * |
||
71 | * @return null|string |
||
72 | */ |
||
73 | public static function username() |
||
79 | |||
80 | /** |
||
81 | * Return the value of the PHP constant or environmental variable |
||
82 | * |
||
83 | * @param string $variable Variable |
||
84 | * |
||
85 | * @return null|string |
||
86 | */ |
||
87 | protected static function variable($variable) |
||
105 | |||
106 | /** |
||
107 | * Return the ReportingCloud password |
||
108 | * |
||
109 | * @return null|string |
||
110 | */ |
||
111 | public static function password() |
||
117 | |||
118 | /** |
||
119 | * Return the ReportingCloud API key |
||
120 | * |
||
121 | * @return null|string |
||
122 | */ |
||
123 | public static function apiKey() |
||
129 | |||
130 | // @codingStandardsIgnoreStart |
||
131 | |||
132 | /** |
||
133 | * Return error message explaining how to configure PHP constant or environmental variables |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | public static function errorMessage() |
||
169 | |||
170 | // @codingStandardsIgnoreEnd |
||
171 | |||
172 | /** |
||
173 | * Print line, wrapped at self::LINE_LENGTH th character |
||
174 | * |
||
175 | * @param string $string String |
||
176 | * |
||
177 | * @return string |
||
178 | */ |
||
179 | public static function writeLn($string) |
||
183 | |||
184 | /** |
||
185 | * Print result line like in a table of contents i.e.: |
||
186 | * |
||
187 | * n: XXX YYY ZZZ....ZZZ |
||
188 | * |
||
189 | * @param int $counter Counter |
||
190 | * @param string $testString Test string |
||
191 | * @param string $testResult Test result |
||
192 | */ |
||
193 | public static function writeLnToc($counter, $testString, $testResult) |
||
202 | } |
||
203 |
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.