Formats attributes value

@param Attribute $attribute

@return mixed|Expr
199102
protected function formatAttributeValue(Attribute $attribute)
    {
        $value = $attribute->getValue();
        
        if ($attribute->getType() === Attribute::TYPE_FUNCTION && strlen($value)) {
            return new Expr($value);
        }
        
        return $value;
    }
929260
public function attr($attribute)
    {
        if (strpos($attribute, ':') !== false) {
            list($ns, $attribute) = explode(':', $attribute, 2);

            return trim((string) $this->el->attributes($ns, true)->{$attribute});
        }
        return trim((string) $this->el->attributes()->{$attribute});
    }
1126090
public function getAttribute($attribute)
    {
        $ret = '';
        if (isset($this->attributeHash[$attribute])) {
            $ret = $this->attributeHash[$attribute];
        }

        return $ret;
    }
160453
protected function attributes($attributes = [])
    {
        $ar = [];

        foreach ($attributes as $key => $value) {
            $element = $this->attribute($key, $value);
            if (!is_null($element)) {
                $ar[] = $element;
            }
        }

        return count($ar) > 0 ? ' '.implode(' ', $ar) : '';
    }
1162880
protected function extractDistinctValues($attribute)
    {
        $attributeData = ValidationData::extractDataFromPath(
            ValidationData::getLeadingExplicitAttributePath($attribute), $this->data
        );

        $pattern = str_replace('\*', '[^.]+', preg_quote($attribute, '#'));

        return Arr::where(Arr::dot($attributeData), function ($value, $key) use ($pattern) {
            return (bool) preg_match('#^'.$pattern.'\z#u', $key);
        });
    }
791823
protected function getAttributeType($attribute)
    {
        $value = $this->data[$attribute];
        if (is_numeric($value)) {
            return 'numeric';
        } elseif (is_array($value)) {
            return 'array';
        } elseif ($value instanceof \SplFileObject) {
            return 'file';
        }

        return 'string';
    }
1172089
private function getHTMLAttributes($attributes)
    {
        $attr = '';
        foreach($attributes as $key => $value) {
            $attr .= $key.'="'.$value.'" ';
        }
        return $attr;
    }
149013
protected function takeAttributeFromDOM($attribute)
    {
        $absoluteAttrName = $attribute->namespaceURI . ':' . $attribute->localName;
        if ($absoluteAttrName == $this->lookupNamespace('yt') . ':' . 'format') {
            $this->_format = $attribute->nodeValue;
        } else {
            parent::takeAttributeFromDOM($attribute);
        }
    }
380216
protected function parseConstantValue($attribute)
    {
        $attribute = strtoupper($attribute);
        $constantName = 'NumberFormatter::'.$attribute;

        if (!\defined($constantName)) {
            throw new \InvalidArgumentException(sprintf('NumberFormatter has no constant "%s".', $attribute));
        }

        return \constant($constantName);
    }
316161
public function getAttributeValueTextRepresentation()
    {
        $result = '';
        $value = $this->getAttributeValueObject();
        if ($value !== null) {
            $number = $value->getValue();
            if ($number !== null) {
                $result = (string) (int) round($number / 20);
            }
        }

        return $result;
    }
664440
public function attribute($attribute) {
		if(!is_array($attribute))
			$attribute = explode('.', $attribute);

		$next = array_shift($attribute);
		if(count($attribute) === 0) {
			if(!isset($this->attributes[$next]))
				return (new static(null))->setParent($this);
			else
				return $this->attributes[$next];
		}

		if($next === '<')
			return $this->parent()->attribute($attribute);
		else {
			if(!isset($this->attributes[$next]))
				return (new static(null))->setParent($this);
			else
				return $this->attributes[$next]->attribute($attribute);
		}
	}
560273
protected function formatAttribute($attributeName)
    {
        if (in_array($attributeName, $this->camelizedAttributes)) {
            return preg_replace_callback(
                '/(^|_|\.)+(.)/', function ($match) {
                    return ('.' === $match[1] ? '_' : '').strtoupper($match[2]);
                }, $attributeName
            );
        }

        return $attributeName;
    }
1250569
public function encoding($attribute = 'video')
    {
        $encodings = $this->encodings;
        if (!is_a($encodings, Collection::class)) {
            $encodings = Encoding::hydrate($encodings);
        }

        return $encodings->first(function ($i, $encoding) use ($attribute) {
            return data_get($encoding, 'encodable_attribute') == $attribute;
        });
    }
1106721
public function getAttribute($attribute)
    {
        // Return the raw value of a translatable attribute if requested
        if ($this->rawValueRequested($attribute)) {
            $rawAttribute = snake_case(str_replace('raw', '', $attribute));
            return $this->attributes[$rawAttribute];
        }
        // Return the translation for the given attribute if available
        if ($this->isTranslated($attribute)) {
            return $this->translate($attribute);
        }
        // Return parent
        return parent::getAttribute($attribute);
    }
90907
public function getHtml($attribute = null)
        {
            if(null !== $attribute) {
                $attribute = strval($attribute);
                if(\Thin\Arrays::exists($attribute, $this->attributes)) {
                    return $attribute . '="' . implode(' ', $this->attributes[$attribute]) . '"';
                }
            } else {
                $return = array();
                foreach(array_keys($this->attributes) as $attrib) {
                    $return[] = $this->getHtml($attrib);
                }
                return implode(' ', $return);
            }

            return '';
        }
1183405
private function formatHtmlAttribute($attributes = [])
    {
        $attrArr = [];
        foreach ($attributes as $name => $val) {
            $attrArr[] = "$name=\"$val\"";
        }

        return implode(' ', $attrArr);
    }
1224578
protected function getDateAttribute($attribute)
        {
            switch ($attribute) {
                case 'Day':
                    return $this->format('d');
                    break;
                case 'Month':
                    return $this->format('m');
                    break;
                case 'Year':
                    return $this->format('Y');
                    break;
                case 'Hour':
                    return $this->format('G');
                    break;
                case 'Minute':
                    return $this->format('i');
                    break;
                case 'Second':
                    return $this->format('s');
                    break;
                case 'DayOfWeek':
                    return $this->format('l');
                    break;
                case 'DayOfWeekAsNumeric':
                    return $this->format('w');
                    break;
                case 'DaysInMonth':
                    return $this->format('t');
                    break;
                case 'DayOfYear':
                    return $this->format('z');
                    break;
                case 'DaySuffix':
                    return $this->format('S');
                    break;
                case 'LeapYear':
                    return (bool) $this->format('L');
                    break;
                case 'AmOrPm':
                    return $this->format('A');
                    break;
                case 'DaylightSavings':
                    return (bool) $this->format('I');
                    break;
                case 'GmtDifference':
                    return $this->format('O');
                    break;
                case 'SecondsSinceEpoch':
                    return $this->format('U');
                    break;
                case 'TimezoneName':
                    return $this->getTimezone()->getName();
                    break;
            }

            throw new \InvalidArgumentException('The date attribute [' . $attribute . '] could not be found.');
        }