Documentation

AbstractBaseDto
in package

AbstractYes

Abstract base class for Data Transfer Objects (DTOs).

Provides common functionality for all DTO classes including data population, array transformation for Canvas API multipart format, and date/time handling. DTOs are used to format and validate data before sending to the Canvas API.

Table of Contents

Properties

$apiPropertyName  : string
The name of the property in the API
$propertyTypeCache  : array<class-string, array<string, array{name: string, builtin: bool}|null>>
Cached property type info, keyed by class name.

Methods

__construct()  : mixed
BaseDto constructor.
toApiArray()  : array<string|int, mixed>
Convert the DTO to an array for API requests
toArray()  : array<string|int, mixed>
Convert the DTO to an array
formatMultipartValue()  : mixed
Format a value for multipart form contents
cast()  : DateTime|mixed
Cast the value to the correct type
getPropertyTypeMap()  : array<string, array{name: string, builtin: bool}|null>
Get type info for each property of this class.

Properties

$apiPropertyName

The name of the property in the API

protected string $apiPropertyName = ''

$propertyTypeCache

Cached property type info, keyed by class name.

private static array<class-string, array<string, array{name: string, builtin: bool}|null>> $propertyTypeCache = []

Avoids constructing a ReflectionClass per property per instantiation.

Methods

__construct()

BaseDto constructor.

public __construct(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>
Tags
throws
Exception

toApiArray()

Convert the DTO to an array for API requests

public toApiArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

toArray()

Convert the DTO to an array

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

formatMultipartValue()

Format a value for multipart form contents

protected static formatMultipartValue(mixed $value) : mixed

Booleans must be converted explicitly: Guzzle's multipart encoder string-casts contents, turning false into an empty string instead of 'false', which Canvas may interpret differently than an unset flag.

Parameters
$value : mixed

The value to format

cast()

Cast the value to the correct type

private cast(mixed $value, string $key) : DateTime|mixed
Parameters
$value : mixed
$key : string
Tags
throws
Exception
Return values
DateTime|mixed

getPropertyTypeMap()

Get type info for each property of this class.

private static getPropertyTypeMap() : array<string, array{name: string, builtin: bool}|null>
Return values
array<string, array{name: string, builtin: bool}|null>
On this page

Search results