import type AttributeCaster from '../../Contracts/AttributeCaster'; import type { AttributeKeys } from './HasAttributes'; type BuiltInCastType = 'boolean' | 'collection' | 'datetime' | 'number' | 'string'; export type CastType = AttributeCaster | BuiltInCastType; export default class CastsAttributes { /** * The attributes that should be cast. * * @protected * * @type {object} */ protected attributeCasts: Record | string, CastType>; /** * The attributes that should be cast. * * @protected * * @type {object} */ get casts(): Record, CastType> | Record; /** * Merge new casts with existing casts on the model. * * @param {object} casts * * @return {this} */ mergeCasts(casts: Record, CastType> | Record): this; /** * Set the casts for the model. * * @param {object} casts * * @return {this} */ setCasts(casts: Record, CastType> | Record): this; /** * Determine whether an attribute should be cast to a determined type. * * @param {string} key * * @return {boolean} */ hasCast(key: AttributeKeys | string): key is BuiltInCastType | 'object'; /** * Get the type of cast for a model attribute. * * @param {string} key * * @protected * * @return {string|undefined} */ protected getCastType(key: AttributeKeys | string): BuiltInCastType | 'object' | undefined; /** * Cast the attribute to the specified type. * * @param {string} key * @param {any} value * @param {string} method - The method to use when interacting with the AttributeCaster. * * @protected * * @internal * * @return {any} */ protected castAttribute(key: AttributeKeys | string, value: any, method?: keyof AttributeCaster): T; /** * Determine whether the given value implements casting. * * @param {any} value * * @protected * * @return {boolean} */ protected implementsCaster(value: any): value is AttributeCaster; /** * Cast the given value to a string. * * @param {string} _key * @param {any} value * * @private * * @return {string} */ private castToString; /** * Cast the given value to number, throw error if it can't be cast. * * @param {string} key * @param {any} value * * @private * * @return {number} */ private castToNumber; /** * Cast the given value to boolean, throw error if it can't be cast. * * @param {string} key * @param {any} value * * @private * * @return {boolean} */ private castToBoolean; /** * Cast to date time using the configured library, throw error if it can't be cast. * * @param {string} key * @param {any} value * * @private * * @return {any} */ private castToDateTime; /** * Cast using the custom casting object. * * @param {string} key * @param {any} value * @param {object} attributes * @param {string} method * * @private * * @return {any} */ private castWithObject; } export {}; //# sourceMappingURL=CastsAttributes.d.ts.map