KMP PHP API Reference

ApiTransport extends AbstractTransport
in package

AbstractYes

Abstract base for HTTP API-based email transports.

Provides shared helpers for extracting data from CakePHP Message objects and sending HTTP requests. Concrete subclasses implement the provider-specific API payload and authentication.

Table of Contents

Properties

$_defaultConfig  : array<string, mixed>
$httpClient  : Client|null

Methods

setHttpClient()  : static
Set a custom HTTP client (useful for testing).
assertSuccessResponse()  : void
Assert a successful HTTP response or throw.
buildResult()  : array{headers: string, message: string}
Build the standard return value for send().
checkRecipient()  : void
Validate that the message has at least one recipient.
formatAttachments()  : array<int, array{name: string, contentType: string, content: string}>
Convert Message attachments to a provider-neutral format.
formatRecipients()  : array<int, array{email: string, name: string}>
Convert Message address array to a flat list of recipient objects.
getHttpClient()  : Client
Get or create the HTTP client instance.
getSender()  : array{email: string, name: string}
Get the sender address from a Message.

Properties

$_defaultConfig

protected array<string, mixed> $_defaultConfig = ['timeout' => 30]

Methods

setHttpClient()

Set a custom HTTP client (useful for testing).

public setHttpClient(Client $client) : static
Parameters
$client : Client
Return values
static

assertSuccessResponse()

Assert a successful HTTP response or throw.

protected assertSuccessResponse(Response $response, string $provider, int ...$acceptedCodes) : void
Parameters
$response : Response

The HTTP response.

$provider : string

Provider name for error messages.

$acceptedCodes : int

HTTP status codes considered successful.

Tags
throws
RuntimeException

On non-success response.

buildResult()

Build the standard return value for send().

protected buildResult(Message $message) : array{headers: string, message: string}
Parameters
$message : Message
Return values
array{headers: string, message: string}

checkRecipient()

Validate that the message has at least one recipient.

protected checkRecipient(Message $message) : void
Parameters
$message : Message

The email message.

Tags
throws
RuntimeException

If no recipients are set.

formatAttachments()

Convert Message attachments to a provider-neutral format.

protected formatAttachments(Message $message) : array<int, array{name: string, contentType: string, content: string}>
Parameters
$message : Message
Return values
array<int, array{name: string, contentType: string, content: string}>

formatRecipients()

Convert Message address array to a flat list of recipient objects.

protected formatRecipients(array<string, string> $addresses) : array<int, array{email: string, name: string}>

CakePHP stores addresses as ['email@example.com' => 'Display Name'].

Parameters
$addresses : array<string, string>
Return values
array<int, array{email: string, name: string}>

getHttpClient()

Get or create the HTTP client instance.

protected getHttpClient() : Client
Return values
Client

getSender()

Get the sender address from a Message.

protected getSender(Message $message) : array{email: string, name: string}
Parameters
$message : Message

The email message.

Tags
throws
RuntimeException

If no sender is set.

Return values
array{email: string, name: string}
On this page

Search results