header('Content-type: application/json;');
include_once 'domain/Club.php';
include_once 'domain/Player.php';
include_once 'domain/Statistics.php';
include_once 'util/Response.php';
include_once 'database/DatabaseBroker.php';
if (isset($_GET['function'])) {
    $db = new DatabaseBroker();
    $response = new Response();
    try {
        $db->openConnection();
        switch ($_GET['function']) {
            case 'getClubs':
                // get clubs list from database
                $clubs = $db->getClubs();
                $response->setValue($clubs);
                break;
            case 'getPlayers':
                // get players list from database
                $clubId = $_GET['clubId'];
                $players = $db->getPlayers($clubId);
                $response->setSuccesfull(true);
                $response->setValue($players);
                break;
            case 'getPlayerStatistics':
                // get statistics for the of the single player
                $playerId = $_GET['playerId'];
                $stat = $db->getStatisticsByPlayerId($playerId);
                $response->setSuccesfull(true);
                $response->setValue($stat);