DataCaster
    
            
            in package
            
        
    
    
    
FinalYes
Table of Contents
Properties
- $castHandlers : array<string, class-string>
- Convert handlers
- $helper : object|null
- $strict : bool
- $types : array<string, string>
- Array of field names and the type of value to cast.
Methods
- __construct() : mixed
- castAs() : mixed
- Provides the ability to cast an item as a specific data type.
Properties
$castHandlers
Convert handlers
        private
            array<string, class-string>
    $castHandlers
     = ['array' => \CodeIgniter\DataCaster\Cast\ArrayCast::class, 'bool' => \CodeIgniter\DataCaster\Cast\BooleanCast::class, 'boolean' => \CodeIgniter\DataCaster\Cast\BooleanCast::class, 'csv' => \CodeIgniter\DataCaster\Cast\CSVCast::class, 'datetime' => \CodeIgniter\DataCaster\Cast\DatetimeCast::class, 'double' => \CodeIgniter\DataCaster\Cast\FloatCast::class, 'float' => \CodeIgniter\DataCaster\Cast\FloatCast::class, 'int' => \CodeIgniter\DataCaster\Cast\IntegerCast::class, 'integer' => \CodeIgniter\DataCaster\Cast\IntegerCast::class, 'int-bool' => \CodeIgniter\DataCaster\Cast\IntBoolCast::class, 'json' => \CodeIgniter\DataCaster\Cast\JsonCast::class, 'timestamp' => \CodeIgniter\DataCaster\Cast\TimestampCast::class, 'uri' => \CodeIgniter\DataCaster\Cast\URICast::class]
    
        [type => classname]
$helper read-only
        private
            object|null
    $helper
     = null
    
    
    
    
    
$strict read-only
        private
            bool
    $strict
     = true
    
    
    
    
    
$types
Array of field names and the type of value to cast.
        private
            array<string, string>
    $types
     = []
    
        [field => type]
Methods
__construct()
    public
                    __construct([array<string, class-string>|null $castHandlers = null ][, array<string, string>|null $types = null ][, object|null $helper = null ][, bool $strict = true ]) : mixed
    Parameters
- $castHandlers : array<string, class-string>|null = null
- 
                    Custom convert handlers 
- $types : array<string, string>|null = null
- 
                    [field => type] 
- $helper : object|null = null
- 
                    Helper object. 
- $strict : bool = true
- 
                    Strict mode? Set to false for casts for Entity. 
castAs()
Provides the ability to cast an item as a specific data type.
    public
                    castAs(mixed $value, string $field[, "get"|"set" $method = 'get' ]) : mixed
    Add ? at the beginning of the type (i.e. ?string) to get null
instead of casting $value when $value is null.
Parameters
- $value : mixed
- 
                    The value to convert 
- $field : string
- 
                    The field name 
- $method : "get"|"set" = 'get'
- 
                    Allowed to "get" and "set"