topics as $topic) {
$this->scores[$topic] = 0;
}
}
public function addScore($topic, $score) {
if (in_array($topic, $this->topics) && is_numeric($score) && $score >= 0 && $score <= 5) {
$this->scores[$topic] = $score;
} else {
throw new Exception("Invalid topic or score");
}
}
public function getScores() {
return $this->scores;
}
public function getTopics() {
return $this->topics;
}
}
// Usage example
$scan = new AIMaturityScan();
// Simulate adding scores (you'd get these from your questionnaire)
$scan->addScore('Responsible AI', 4.5);
$scan->addScore('AI Trends', 3.8);
$scan->addScore('AI Strategy', 4.2);
$scan->addScore('Organization', 2.5);
$scan->addScore('People', 3.0);
$scan->addScore('Data', 4.0);
$scan->addScore('Controls', 3.5);
// Get the data for the graph
$graphData = $scan->getScores();
// Output as JSON (which can be used by a JavaScript charting library)
echo json_encode($graphData);