| Total Complexity | 5 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class js |
||
| 6 | { |
||
| 7 | public static function js_str($s) |
||
| 10 | } |
||
| 11 | |||
| 12 | public static function js_array(array $array) |
||
| 13 | { |
||
| 14 | $temp = array_map(function ($index) { |
||
| 15 | return self::js_str($index); |
||
| 16 | }, $array); |
||
| 17 | |||
| 18 | return '[' . implode(',', $temp) . ']'; |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Create javascript variable. |
||
| 23 | * |
||
| 24 | * @param string $variable variable name |
||
| 25 | * @param string|array|object $content array object will turn into JSON javascript object |
||
| 26 | * |
||
| 27 | * @return string var name = content; |
||
| 28 | */ |
||
| 29 | public static function var(string $variable, $content) |
||
| 39 | } |
||
| 40 | } |
||
| 41 |