4 function error($text) {
9 function output($text) {
14 // Check a file path is provided
15 if (count($argv) < 2) {
16 error("Path to JSON report required");
19 // Check file path exists
20 $reportFile = realpath($argv[1]);
21 if (!file_exists($reportFile)) {
22 error("JSON report file not found at {$reportFile}");
25 $reportContent = file_get_contents($reportFile);
26 $report = json_decode($reportContent, true);
27 if (is_null($report)) {
28 error("Could not read JSON content from file {$reportFile}");
31 foreach ($report['data'] as $userData) {
32 $fullName = $userData['user']['fullName'];
33 $languages = array_map(function($lang) {
34 return '*' . $lang['name'] . '*';
35 }, $userData['languages']);
37 if (count($languages) === 0) {
41 $langString = implode(", ", $languages);
42 output("* {$fullName} - {$langString}");