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

@param  string  $key
@param  array|string|null  $types
@return bool
354710
public function hasCast($key, $types = null)
    {
        if (array_key_exists($key, $this->getCasts())) {
            return $types ? in_array($this->getCastType($key), (array) $types, true) : true;
        }

        return false;
    }
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);
    }
1334127
private function determine( $type, $key_type = false ) {
		if ( ! $key_type && $this->non_scalar_type_exists( $type ) ) {
			return $type;
		}

		if ( $scalar_type = $this->determine_scalar( $type ) ) {
			if ( $key_type && (in_array( $scalar_type, array( 'double', 'boolean' ) )) ) {
				throw new InvalidArgumentException( 'This type is not supported as a key.' );
			}

			return $scalar_type;
		}

		throw new InvalidArgumentException( 'This type does not exist.' );
	}
77212
public function hasAttr($key)
    {
        if(isset($this->attributes[$key]))
            return true;

        return $this->finding->hasAttribute($key);
    }
213703
protected function hasItem($key, $type)
	{
		if(array_key_exists($type, $this->storage) && array_key_exists($key, $this->storage[$type]))
		{
			return true;
		}

		return false;
	}
794048
public function isTranslationAttribute($key)
    {
        if ($this->isSpecialAttribute($key))
        {
            return false;
        }

        // When there is no node type we exclude source attributes
        return $this->_isTranslationAttribute($key) ||
        (is_null($this->getNodeTypeName()) ? false : $this->isSourceAttribute($key));
    }
480879
private function phpize(array $array, string $key, string $type)
    {
        if (!isset($array[$key])) {
            return null;
        }

        switch ($type) {
            case 'bool':
                if (\is_bool($array[$key])) {
                    return $array[$key];
                }
                break;
            case 'string':
                if (\is_string($array[$key])) {
                    return $array[$key];
                }
                break;
        }

        throw new InvalidArgumentException(sprintf('The property "%s" must be a "%s", "%s" given.', $key, $type, \gettype($array[$key])));
    }
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
            );
        }
    }
734999
private function hasCustomSetCaster($key)
    {
        return $this->hasCast($key) && method_exists($this, $this->getCustomSetCaster($key));
    }
375673
public function has($key): bool
    {
        return $this->exists($key) && null !== $this->attributes[$key];
    }
328958
private function checkType($type)
    {
        $isInType = true;

        foreach ($this->getKeys() as $key) {
            if (gettype($key) !== $type) {
                $isInType = false;
                break;
            }
        }

        return $isInType;
    }
1100864
public function setType($types)
    {
        if (!is_array($types)) {
            $types = [$types];
        }

        $typesToSet = [];
        foreach ($types as $type) {
            if ($type === 'int') {
                $type = 'integer';
            }
            if ($type === 'hash') {
                $type = 'object';
            }

            // handle non-primitive types
            if (!in_array($type, $this->primitiveTypes)) {
                $setType = 'string';
                if (isset($this->specialTypeMapping[$type])) {
                    $setType = $this->specialTypeMapping[$type];
                }
                $typesToSet[] = $setType;

                if (isset($this->formatOverrides[$type])) {
                    $type = $this->formatOverrides[$type];
                }

                $this->setFormat($type);
            } else {
                $typesToSet[] = $type;
            }
        }

        $this->type = new SchemaType($typesToSet);
    }
335875
public function isEntityAttribute(string $key)
    {
        $key = $this->getEntityAttributeName($key);

        return $this->getEntityAttributes()->has($key);
    }
763148
protected function setProperties(
        $type = null,
        $key = null,
        $attributes = [],
        $validKeys = []
    ) {
        if (isset($this->properties['type']) && $this->properties['type'] == $type) {
            foreach ($attributes as $attribute => $value) {
                if (in_array($attribute, $validKeys)) {
                    $this->{$key}[$attribute] = $value;
                }
            }
        }
    }
48210
public function defaultTypes(array $types = null)
    {
        deprecationWarning(
            'TypeMapTrait::defaultTypes() is deprecated. ' .
            'Use TypeMapTrait::setDefaultTypes()/getDefaultTypes() instead.'
        );
        if ($types !== null) {
            return $this->setDefaultTypes($types);
        }

        return $this->getDefaultTypes();
    }
114224
public function hasAttribute($key, $subKey = null)
    {
        // Normalize key.
        $key = $this->normalizeAttributeKey($key);
        
        if (is_null($subKey)) {
            return Arr::has($this->attributes, $key);
        }

        return Arr::has($this->attributes, "$key.$subKey");
    }
408260
public function lookaheadTypeIsAnyOf(array $types): bool
    {
        return isset($this->tokens[$this->position]) && $this->tokens[$this->position]->typeEqualsAnyOf($types);
    }