$dataCaster App\Core\Lib\DataCaster\DataCaster#82 (2)
  • Properties (2)
  • Methods (5)
  • private types -> array (0)
    private castHandlers -> array (14)
    array => string (38) "App\Core\Lib\DataCaster\Cast\ArrayCast"
    bool => string (40) "App\Core\Lib\DataCaster\Cast\BooleanCast"
    boolean => string (40) "App\Core\Lib\DataCaster\Cast\BooleanCast"
    csv => string (36) "App\Core\Lib\DataCaster\Cast\CSVCast"
    datetime => string (41) "App\Core\Lib\DataCaster\Cast\DatetimeCast"
    date => string (37) "App\Core\Lib\DataCaster\Cast\DateCast"
    double => string (38) "App\Core\Lib\DataCaster\Cast\FloatCast"
    float => string (38) "App\Core\Lib\DataCaster\Cast\FloatCast"
    int => string (40) "App\Core\Lib\DataCaster\Cast\IntegerCast"
    integer => string (40) "App\Core\Lib\DataCaster\Cast\IntegerCast"
    int-bool => string (40) "App\Core\Lib\DataCaster\Cast\IntBoolCast"
    json => string (37) "App\Core\Lib\DataCaster\Cast\JsonCast"
    timestamp => string (42) "App\Core\Lib\DataCaster\Cast\TimestampCast"
    uri => string (36) "App\Core\Lib\DataCaster\Cast\URICast"
  • public __construct(?array $castHandlers = null, ?array $types = null) Constructor. Optionally merges custom cast handlers and field type definitions.
    new \App\Core\Lib\DataCaster\DataCaster()
    /**
     * Constructor.
     * Optionally merges custom cast handlers and field type definitions.
     * @param array<string,class-string>|null $castHandlers Optional custom cast handlers to merge.
     * @param array<string,string>|null $types Optional type definitions for fields.
     */
    
    Defined in .../app/Core/Lib/DataCaster/DataCaster.php:63
    public addCastHandlers(array $handlers): static Adds or overrides cast handlers.
    $dataCaster->addCastHandlers()
    /**
     * Adds or overrides cast handlers.
     * @param array<string,class-string> $handlers
     * @return $this
     */
    
    Defined in .../app/Core/Lib/DataCaster/DataCaster.php:79
    public castAs($value, string $field, string $method = 'get'): mixed Casts a value according to its configured type for a given field. Supports nu...
    $dataCaster->castAs()
    /**
     * Casts a value according to its configured type for a given field.
     * Supports nullable types prefixed with '?' and parameterized types like "json[array]".
     * @param mixed $value Value to be cast.
     * @param string $field Field name to determine type for.
     * @param 'get'|'set' $method Determines which handler method to call.
     * @return mixed
     * @throws DataCasterException If invalid cast method or nullability rules are violated.
     * @throws InvalidArgumentException If no handler exists for the given type.
     */
    
    Defined in .../app/Core/Lib/DataCaster/DataCaster.php:108
    public getTypes(): array Returns the mapping of field names to their cast types.
    $dataCaster->getTypes()
    /**
     * Returns the mapping of field names to their cast types.
     * @return array<string,string>
     */
    
    Defined in .../app/Core/Lib/DataCaster/DataCaster.php:160
    public setTypes(array $types): static Sets the mapping of field names to their cast types.
    $dataCaster->setTypes()
    /**
     * Sets the mapping of field names to their cast types.
     * @param array<string,string> $types
     * @return $this
     */
    
    Defined in .../app/Core/Lib/DataCaster/DataCaster.php:170