<?php

if (!function_exists('getGitDataFromRequest')) {

    function getGitDataFromRequest($requestData): array
    {
        $gitData = [
            'email' => '<>',
            'name' => 'CFEngine Build API'
        ];

        if (isset($requestData->gitEmail) || !empty($requestData->gitEmail)) {
            $gitData['email'] = (string)$requestData->gitEmail;
        }

        if (isset($requestData->gitName) || !empty($requestData->gitName)) {
            $gitData['name'] = (string)$requestData->gitName;
        }

        if (isset($requestData->gitMessage) || !empty($requestData->gitMessage)) {
            $gitData['message'] = (string)$requestData->gitMessage;
        }

        return $gitData;
    }

}
