KMP PHP API Reference

RetentionPolicyService
in package

Calculates document retention dates based on JSON retention policy definitions.

Interprets retention rules with anchor types (gathering_end_date, upload_date, permanent) and duration fields (years, months, days) to determine document expiration dates.

Policy JSON format: {"anchor": "gathering_end_date", "years": 2, "months": 0, "days": 0}

Tags
see
WaiverType

Source of retention policy JSON

see
ServiceResult

Standard service result pattern

Table of Contents

Constants

VALID_ANCHORS  = ['gathering_end_date', 'upload_date', 'permanent']
Valid anchor types for retention policies

Methods

calculateRetentionDate()  : ServiceResult
Calculate retention date based on policy and anchor date
getDescription()  : string
Get human-readable description of a retention policy
getHumanReadableDescription()  : string
Get human-readable description of a retention policy
isExpired()  : bool
Check if a waiver is expired based on retention date
validatePolicy()  : ServiceResult
Validate retention policy JSON structure
addDurationToDate()  : Date
Add duration to a date
getAnchorDate()  : Date|null
Get the anchor date based on anchor type

Constants

VALID_ANCHORS

Valid anchor types for retention policies

private mixed VALID_ANCHORS = ['gathering_end_date', 'upload_date', 'permanent']

Methods

calculateRetentionDate()

Calculate retention date based on policy and anchor date

public calculateRetentionDate(string $policyJson[, Date|null $gatheringEndDate = null ][, Date|null $uploadDate = null ]) : ServiceResult
Parameters
$policyJson : string

JSON-encoded retention policy

$gatheringEndDate : Date|null = null

Gathering end date (required for gathering_end_date anchor)

$uploadDate : Date|null = null

Upload date (required for upload_date anchor, defaults to today)

Return values
ServiceResult

Success with Date object (or null for permanent retention), or failure with error message

getDescription()

Get human-readable description of a retention policy

public getDescription(string $policyJson) : string
Parameters
$policyJson : string

JSON-encoded retention policy

Return values
string

Human-readable description

getHumanReadableDescription()

Get human-readable description of a retention policy

public getHumanReadableDescription(string $policyJson) : string

Parses the retention policy JSON and generates a user-friendly description suitable for display in UI or documentation.

Parameters
$policyJson : string

JSON-encoded retention policy

Return values
string

Human-readable description following the format: "Retain for X years, Y months, Z days after [anchor]" or "Retain permanently" for permanent retention

isExpired()

Check if a waiver is expired based on retention date

public isExpired(Date $retentionDate[, Date|null $checkDate = null ]) : bool
Parameters
$retentionDate : Date

The calculated retention date

$checkDate : Date|null = null

Date to check against (defaults to today)

Return values
bool

True if expired (retention date has passed)

validatePolicy()

Validate retention policy JSON structure

public validatePolicy(string $policyJson) : ServiceResult
Parameters
$policyJson : string

JSON string to validate

Return values
ServiceResult

Success with parsed policy array, or failure

addDurationToDate()

Add duration to a date

private addDurationToDate(Date $date, int $years, int $months, int $days) : Date
Parameters
$date : Date

Starting date

$years : int

Years to add

$months : int

Months to add

$days : int

Days to add

Return values
Date

New date with duration added

getAnchorDate()

Get the anchor date based on anchor type

private getAnchorDate(string $anchorType, Date|null $gatheringEndDate, Date|null $uploadDate) : Date|null
Parameters
$anchorType : string

Type of anchor

$gatheringEndDate : Date|null

Gathering end date

$uploadDate : Date|null

Upload date

Return values
Date|null

The anchor date or null if not available


        
On this page

Search results