Determine whether an attribute should be cast to a native type.

@param  string            $key   A string of attribute key.
@param  array|string|null $types Optional, list of possible types.
@return bool
182823
public function has_cast( $key, $types = null ) {
		if ( array_key_exists( $key, $this->get_casts() ) ) {
			return $types ? in_array( $this->get_cast_type( $key ), (array) $types, true ) : true;
		}

		return false;
	}
675268
protected function mutateExtensionAttribute($key, $type)
    {
        $value = $this->getAttributeFromArray($key);

        $mutation = $this->{'make' . studly_case($type) . 'TypeMutation'}($value);

        $this->mutations[$key] = $mutation;

        return $mutation;
    }
244762
public function attr($key = null, $default = null)
    {
        return is_null($key) ? $this->attributes : array_get($this->attributes, $key, $default);
    }
356330
public static function has($key, $type = 'ses')
    {
        return ($GLOBALS['TSFE']->fe_user->getKey(self::isType($type), $key)) ? true : false;
    }
382529
protected function applyCast(string $key): void
    {
        $casts = $this->casts();

        if ( ! count($casts) || ! array_key_exists($key, $casts)) {
            return;
        }

        if ( ! isset($this->attributes[ $key ])) {
            $value = null;
        } else {
            $value = $this->attributes[ $key ];
        }

        // If the cast type is a simple scalar, apply it and return
        if (in_array($casts[ $key ], static::SCALAR_CASTS)) {
            $this->attributes[ $key ] = call_user_func([$this, 'castValueAs' . ucfirst($casts[ $key ])], $value);
            return;
        }

        // Otherwise attempt a data object cast
        $dataObjectClass = $casts[ $key ];
        $dataObjectArray = false;

        // If the model is postfixed with [], an array of models is expected
        if (substr($dataObjectClass, -2) === '[]') {
            $dataObjectClass = substr($dataObjectClass, 0, -2);
            $dataObjectArray = true;
        }

        if (null === $value) {
            if ($dataObjectArray) {
                $this->attributes[ $key ] = [];
                return;
            }

            if ($this->castUnsetObjects) {
                $this->attributes[ $key ] = $this->makeNestedDataObject($dataObjectClass, [], $key);
            }
            return;
        }

        if ($dataObjectArray) {

            if (is_array($this->attributes[ $key ])) {

                foreach ($this->attributes[ $key ] as $index => &$item) {

                    if (null === $item && ! $this->castUnsetObjects) {
                        continue;
                    }

                    if ( ! ($item instanceof $dataObjectClass)) {

                        $item = $this->makeNestedDataObject($dataObjectClass, $item ?: [], $key . '.' . $index);
                    }
                }
            }

            unset($item);

            return;
        }

        // Single data object
        if ( ! ($this->attributes[ $key ] instanceof $dataObjectClass)) {
            $this->attributes[ $key ] = $this->makeNestedDataObject(
                $dataObjectClass,
                $this->attributes[ $key ],
                $key
            );
        }
    }
85473
public function type($key)
	{
		if (Str::endsWith($key, ':queued')) {
			$key = str_replace(':queued', '', $key);
		}

		return $this->database->type($key);
	}
361225
protected function castAttribute($key, $value)
    {
        if ($value === null) {
            return $value;
        }

        if ($this->getCastType($key) === 'serialize') {
            return $this->fromSerialize($value);
        }

        return parent::castAttribute($key, $value);
    }
430353
protected function cast_attribute( $key, $value ) {
		if ( is_null( $value ) ) {
			return $value;
		}

		switch ( $this->get_cast_type( $key ) ) {
			case 'int':
			case 'integer':
				return (int) $value;
			case 'real':
			case 'float':
			case 'double':
				return (float) $value;
			case 'string':
				return (string) $value;
			case 'array':
				return (array) $value;
			case 'bool':
			case 'boolean':
				return (bool) $value;
			default:
				return $value;
		}
	}
148303
protected function _attr_type(&$attributes)
	{
		switch (strtoupper($attributes['TYPE']))
		{
			case 'TINYINT':
				$attributes['TYPE'] = 'SMALLINT';
				$attributes['UNSIGNED'] = FALSE;
				return;
			case 'MEDIUMINT':
				$attributes['TYPE'] = 'INTEGER';
				$attributes['UNSIGNED'] = FALSE;
				return;
			case 'INTEGER':
				$attributes['TYPE'] = 'INT';
				return;
			case 'BIGINT':
				$attributes['TYPE'] = 'INT64';
				return;
			default: return;
		}
	}
776911
public function isActionMessage($keys = null) {
        $messages = $this->getAttribute(ACTION_MESSAGES_KEY);
        if (!$messages)
            return $this->isActionError($keys);

        if (is_string($keys))
            $keys = [$keys];

        if (is_array($keys)) {
            foreach ($keys as $key) {
                if (key_exists($key, $messages)) return true;
            }
            if ($keys)
                return $this->isActionError($keys);
            $keys = null;
        }

        if (is_null($keys))
            return true;
        throw new IllegalTypeException('Illegal type of parameter $keys: '.gettype($keys));
    }
1066270
public function isMappedAttribute($name, $key)
    {
        $map = isset($this->attributemap[$name]) ? $this->attributemap[$name] : [];

        if (isset($this->attributemap['*'])) {
            $map = array_merge($this->attributemap['*'], $map);
        }

        return in_array($key, $map);
    }
1258172
protected static function passed($type, $key = null, $default = null)
    {
        return Session::get(
            $type . ($key !== null ? '.' . $key : ''),
            $key === null && $default === null ? [] : $default
        );
    }
1030659
public static function setDataTypes(array $types) : void
    {
        // Datatypes key validation
        foreach ($types as $key => $value) {
            if (!preg_match('/^[A-Za-z0-9-_]+$/', $key)) {
                throw new \UnexpectedValueException("<b>$key</b> is not a valid datatype key", 1);

            } elseif (!is_string($value)) {
                throw new \LogicException("<b>$key</b> must have a string value", 1);
            }
        }

        // Put keys between brackets
        self::$datatypes = array_combine(
            array_map(function ($t) {
                return '/\{' . $t . '\}/';
            }, array_keys($types)),
            $types
        );
    }
994593
public function __isset($key)
    {
        return (isset($this->attributes[$key]) && null !== $this->getAttributeValue($key));
    }
41624
public static function isValidKey($key) {
        if(!is_string($key)) {
            throw EnumerationException::invalidKeyType(gettype($key));
        }

        return array_key_exists($key, self::toArray());
    }
963089
public function setAllowedMimeTypes($types = '*')
        {
            if(is_string($types))
            {
                if ('*' !== $types) {
                    $types = (array) $types;
                }else{
                    $this->allowedTypes = $types;
                    return $this;
                }
            }

            if(is_array($types))
            {
                $this->allowedTypes = $types;
                return $this;
            }else{
                return false;
            }
        }
955285
public function originalIsEquivalent($key, $current)
    {
        if (! array_key_exists($key, $this->original)) {
            return false;
        }

        $original = $this->getOriginal($key);

        if ($current === $original) {
            return true;
        } elseif (is_null($current)) {
            return false;
        } elseif ($this->isDateAttribute($key)) {
            return $this->fromDateTime($current) ===
                   $this->fromDateTime($original);
        } elseif ($this->hasCast($key)) {
            return $this->castAttribute($key, $current) ===
                   $this->castAttribute($key, $original);
        }

        return is_numeric($current) && is_numeric($original)
                && strcmp((string) $current, (string) $original) === 0;
    }