SparkPost\Transmission::formatCarbonCopy PHP Method

formatCarbonCopy() private method

Formats cc list into recipients list and adds the CC header to the content.
private formatCarbonCopy ( array $payload ) : array
$payload array - the request body
return array - the modified request body
    private function formatCarbonCopy($payload)
    {
        if (isset($payload['cc'])) {
            $ccAddresses = [];
            for ($i = 0; $i < count($payload['cc']); ++$i) {
                array_push($ccAddresses, $this->toAddressString($payload['cc'][$i]['address']));
            }
            // set up the content headers as either what it was before or an empty array
            $payload['content']['headers'] = isset($payload['content']['headers']) ? $payload['content']['headers'] : [];
            // add cc header
            $payload['content']['headers']['CC'] = implode(',', $ccAddresses);
            $payload = $this->addListToRecipients($payload, 'cc');
        }
        return $payload;
    }