1 | <?php |
||
21 | class Helper |
||
22 | { |
||
23 | /** |
||
24 | * Line length in characters (used to wrap long lines) |
||
25 | */ |
||
26 | const LINE_LENGTH = 80; |
||
27 | |||
28 | /** |
||
29 | * Name of username PHP constant or environmental variables |
||
30 | * |
||
31 | * @const REPORTING_CLOUD_USERNAME |
||
32 | */ |
||
33 | const USERNAME = 'REPORTING_CLOUD_USERNAME'; |
||
34 | |||
35 | /** |
||
36 | * Name of password PHP constant or environmental variables |
||
37 | * |
||
38 | * @const REPORTING_CLOUD_PASSWORD |
||
39 | */ |
||
40 | const PASSWORD = 'REPORTING_CLOUD_PASSWORD'; |
||
41 | |||
42 | /** |
||
43 | * Return error message explaining how to configure PHP constant or environmental variables |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | public static function errorMessage() |
||
78 | |||
79 | /** |
||
80 | * Return the ReportingCloud username |
||
81 | * |
||
82 | * @return null|string |
||
83 | */ |
||
84 | public static function username() |
||
90 | |||
91 | /** |
||
92 | * Return the ReportingCloud password |
||
93 | * |
||
94 | * @return null|string |
||
95 | */ |
||
96 | public static function password() |
||
102 | |||
103 | /** |
||
104 | * Check ReportingCloud credentials, which have been defined in environment variables, otherwise terminate script |
||
105 | * execution with error code 1 |
||
106 | */ |
||
107 | public static function checkCredentials() |
||
116 | |||
117 | /** |
||
118 | * Return the value of the PHP constant or environmental variable |
||
119 | * |
||
120 | * @param string $variable Variable |
||
121 | * |
||
122 | * @return null|string |
||
123 | */ |
||
124 | protected static function variable($variable) |
||
142 | |||
143 | /** |
||
144 | * Print line, wrapped at self::LINE_LENGTH th character |
||
145 | * |
||
146 | * @param string $string String |
||
147 | * @return string |
||
148 | */ |
||
149 | public static function writeLn($string) |
||
153 | |||
154 | /** |
||
155 | * Print result line like in a table of contents i.e.: |
||
156 | * |
||
157 | * n: XXX YYY ZZZ....ZZZ |
||
158 | * |
||
159 | * @param integer $counter Counter |
||
160 | * @param string $testString Test string |
||
161 | * @param string $testResult Test result |
||
162 | */ |
||
163 | public static function writeLnToc($counter, $testString, $testResult) |
||
172 | |||
173 | } |
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.