Globals API

Module: Globals

Namespace root: DafGlobals

Collections

DafGlobals\Collections\ICollection, ReadOnlyCollection, Collection

Common API:

  • Add, Remove, Clear (mutable in Collection)
  • Skip, Take, Any, Count
  • Map, ForEach, Reverse
  • FirstOrDefault, SingleOrDefault, Where, FindKey, ToArray

Dates

  • IDate: FromString, FromDateTime, Format, ToDateTime, AddDays/AddMonths/AddYears, Compare, Equals
  • BaseDate implements shared immutable behavior and JSON serialization.
  • DateOnly: FromString, Today (normalized midnight).
  • DateTime: FromString, Now, AddHours, AddMinutes.

Path

  • Path::Combine(string ...$parts): string
  • Path::ResolveRelative(string $base, string $relative): string

ObjectMapper

  • ObjectMapper::Map(object $source, object $target, array $mapping = []): object
  • Supports rename mapping, transform callbacks, and optional getter/setter strategy flags.

Usage Example

PHP
<?php
$dto = new UserDto();
ObjectMapper::Map($entity$dto, [
    'Id' => 'UserId',
    'CreatedAt' => [
        'target' => 'CreatedAtIso',
        'map' => fn($v) => $v?->Format('c')
    ]
]);