This util method is used to ensure the attribute is an integer and uses it's id if it is an object.

@param AttributeInterface|integer $attribute Product attribute.

@return integer
964902
private function getAttributeId($attribute)
    {
        $attributeId = $attribute;

        if (is_object($attribute)) {
            $attributeId = $attribute->getAttributeId();
        }

        return $attributeId;
    }
540209
public function addAttribute(Attribute$attribute) : Attributes
	{
		$this->getItems();//max sure is array
		$this->attributes[$attribute->getName()] = $attribute;
		return $this;
	}
556741
protected function getCurrentLdapAttributeValue($attribute)
    {
        if (!$this->getDn() || !$this->getLdapConnection()) {
            throw new AttributeConverterException(sprintf('Unable to query for the current "%s" attribute.', $attribute));
        }

        $query = new LdapQueryBuilder($this->getLdapConnection());
        try {
            return $query->select($attribute)
                ->where($query->filter()->present('objectClass'))
                ->setBaseDn($this->getDn())
                ->setScopeBase()
                ->getLdapQuery()
                ->getSingleScalarOrNullResult();
        } catch (EmptyResultException $e) {
            throw new AttributeConverterException(sprintf('Unable to find LDAP object: %s', $this->getDn()));
        }
    }
937
public function getAttribute($attribute)
    {
        return !empty($this->attributes[$attribute]) ? $this->attributes[$attribute] : null;
    }
583763
protected function getDynamicEncrypted($attribute)
    {
        // Dynamically get the encrypted attributes
        if ($this->isEncryptable($attribute)) {
            // Decrypt only encrypted values
            if ($this->isEncrypted($attribute)) {
                return $this->getEncryptedAttribute($attribute);
            }
        }
    }
501462
protected function resolveAttributeName($attribute)
    {
        $result = preg_grep("/^$attribute$/i", array_keys($this->attributes));
        if (empty($result)) {
            throw new InvalidArgumentException(sprintf('Unable to resolve attribute "%s".', $attribute));
        }

        return reset($result);
    }
600418
public function getAttribute(AttributeType $attributeType): Attribute
    {
        $attribute = null;

        $this->attributes->filter(function ($attr) use ($attributeType, &$attribute) {
            if ($attr->getAttributeType() === $attributeType) {
                $attribute = $attr;
            }
        });

        if ($attribute === null) {
            throw new InvalidArgumentException(sprintf('Attribute with name « %s » not found for product « %s »', $attributeName, $this->getName()));
        }

        return $attribute;
    }
199102
protected function formatAttributeValue(Attribute $attribute)
    {
        $value = $attribute->getValue();
        
        if ($attribute->getType() === Attribute::TYPE_FUNCTION && strlen($value)) {
            return new Expr($value);
        }
        
        return $value;
    }
1092078
public static function create($attribute, $value)
    {
        $attributesType = self::getAllAttributeType();
        foreach ($attributesType as $attributeType) {
            if ($attributeType->isMember($attribute)) {
                return $attributeType->create($value);
            }
        }

        return $value;
    }
1047031
protected function getAttribute($attribute)
	{
		// The developer may dynamically specify the array of custom attributes
		// on this Validator instance. If the attribute exists in this array
		// it takes precedence over all other ways we can pull attributes.
		if (isset($this->customAttributes[$attribute]))
		{
			return $this->customAttributes[$attribute];
		}

		$key = "validation.attributes.{$attribute}";

		// We allow for the developer to specify language lines for each of the
		// attributes allowing for more displayable counterparts of each of
		// the attributes. This provides the ability for simple formats.
		if (($line = $this->translator->trans($key)) !== $key)
		{
			return $line;
		}

		// If no language line has been specified for the attribute all of the
		// underscores are removed from the attribute name and that will be
		// used as default versions of the attribute's displayable names.
		return str_replace('_', ' ', snake_case($attribute));
	}
267765
protected function isAllowedEAVAttribute(
        DataInterface $object,
        AttributeInterface $attribute,
        /** @noinspection PhpUnusedParameterInspection */
        $format = null,
        array $context = []
    ) {
        $options = $attribute->getOption(static::SERIALIZER_OPTIONS, []);

        // Ignore attributes set as serializer: expose: false
        if (array_key_exists(static::EXPOSE_KEY, $options) && !$options[static::EXPOSE_KEY]) {
            return false;
        }

        // If normalizing by reference, we just check if it's among the allowed attributes
        if ($this->byReferenceHandler->isByReference($context)) {
            return \in_array($attribute->getCode(), $this->referenceAttributes, true);
        }

        // Also check ignored attributes
        if (\in_array($attribute->getCode(), $this->ignoredAttributes, true)) {
            return false;
        }

        return $this->isEAVGroupAllowed($object, $attribute, $context);
    }
556991
public function getAttribute($attribute)
    {
        switch ($attribute) {
            case self::PROPEL_ATTR_CACHE_PREPARES:
                return $this->isCachePreparedStatements;
                break;
            default:
                return $this->connection->getAttribute($attribute);
        }
    }
103929
public function getAttributeChangeset(AttributeInterface $attribute)
    {
        if (!array_key_exists($attribute->getCode(), $this->getValuesChangeset())) {
            return [];
        }

        return $this->getValuesChangeset()[$attribute->getCode()];
    }
1286832
protected function attributeHasValue($attribute, $value)
    {
        $attribute = $this->resolveAttributeName($attribute);

        if (is_array($this->attributes[$attribute])) {
            return in_array($value, $this->attributes[$attribute]);
        } else {
            return ($this->attributes[$attribute] == $value);
        }
    }
833622
protected function getAttributeType($attribute)
    {
        // We assume that the attributes present in the file array are files so that
        // means that if the attribute does not have a numeric rule and the files
        // list doesn't have it we'll just consider it a string by elimination.
        if ($this->hasRule($attribute, $this->numericRules)) {
            return 'numeric';
        } else if ($this->hasRule($attribute, array('Array'))) {
            return 'array';
        } else if (array_key_exists($attribute, $this->files)) {
            return 'file';
        }

        return 'string';
    }
751608
public int getAttributeAsInt(AnnotationAttributeType attribute) {
		String temp = attributes.get(attribute.getValue());

		return Integer.parseInt(temp);
	}
529423
public function getAttributeText($attribute) {
		$items = $this->getAttributeItems($attribute, 0, false, true);

		return isset($items[$this->$attribute]) ? $items[$this->$attribute] : null;
	}