Generates attributes
@method attributes
@param  array|string    $attributes Given attributes
@return string      Returns attributes in inline form
428833
protected function attributes($attributes)
    {
        if (!is_array($attributes)) {
            return $attributes;
        }

        $attr = '';
        foreach ($attributes as $attribute => $value) {
            if (is_int($attribute)) {
                $attribute = $value;
            }
            $attr .= ' ' . $attribute . '="' . $value . '"';
        }

        return $attr;
    }
1328695
public static function attributes(array $attributes = null) : string
    {
        if (empty($attributes)) return '';

        // Init var
        $sorted = [];

        foreach (Html::$attribute_order as $key) {

            if (isset($attributes[$key])) {
                // Add the attribute to the sorted list
                $sorted[$key] = $attributes[$key];
            }

        }

        // Combine the sorted attributes
        $attributes = $sorted + $attributes;

        $compiled = '';

        foreach ($attributes as $key => $value) {

            if ($value === NULL) {
                // Skip attributes that have NULL values
                continue;
            }

            if (is_int($key)) {
                // Assume non-associative keys are mirrored attributes
                $key = $value;
            }

            // Add the attribute value
            $compiled .= ' '.$key.'="'.Html::toText($value).'"';
        }

        return $compiled;
    }
627618
public function attr(array $attributes)
    {
        $result = '';

        foreach ($attributes as $attribute => $value) {
            $result .= ' '.(is_int($attribute) ? $value : $attribute.'="'.str_replace('"', '&quot;', $value).'"');
        }

        return $result;
    }
430674
private function formatProductAttributes(array $attributes) {

    $formatted = [];

    foreach ($attributes as $name => $value) {
      if (is_string($value)) {
        $valueAsString = $value;
      }
      else {
        // Does the key=>value store module expect serialize?
        // (I would prefer JSON)
        // >> Yes. (But are we using the key=>value store for this?)
        // Can we pass it the object and get 'auto serialize/unserialize'?
        // >> Maybe.
        if (is_array($value) || is_object($value)) {
          $valueAsString = serialize($value);
        }
        else {
          // 'Trust' PHP's type-casting for now.
          $valueAsString = (string) $value;
        }
      }

      $formatted[] = [
        'key' => $name,
        'value' => $valueAsString,
      ];
    }

    return $formatted;
  }
647021
public function datagridAttributes(array $attributes)
    {
        $result = '';

        foreach ($attributes as $attributeName => $attributeValue) {
            $result .= ' '.$attributeName.'="'.$attributeValue.'"';
        }

        return $result;
    }
807106
public function replaceAttributes(array $attributes)
    {
        $url = self::makeAttributeUrl();
        $data = json_encode(array("attribute" => $attributes));

        $replaced = $this->service->prepAndSend($url, array(200), 'PUT', $data, true);
        $replaced = json_decode($replaced);
        $result = array();
        foreach ($replaced->attribute as $attr) {
            $result[] = Attribute::createFromJSON($attr);
        }
        return $result;
    }
533202
protected function attributesArrayToText($attributes)
    {
        $text = "";

        foreach ($attributes as $name => $value)
        {
            $text .= "{$name}=\"{$value}\" ";
        }

        $text = rtrim($text);

        return $text;
    }
616603
private function getAttributesXpath(array $attributes)
    {
        $xpath = '';
        if (!empty($attributes)) {
            $parts = [];
            foreach ($attributes as $key => $value) {
                $parts[] = '@' . $key . '="' . $value . '"';
            }

            $xpath .= '[' . implode(' and ', $parts) . ']';
        }

        return $xpath;
    }
689020
protected function _cleanAttributes($attributes)
    {
        foreach ($attributes as $key => $value) {
            if (is_int($key) || in_array($key, $this->_config['ignored'])) {
                unset($attributes[$key]);
            } else if ($key != 'memberof' && is_array($value) && count($value) == 1) {
                $attributes[$key] = $value[0];
            }
        }

        return $attributes;
    }
514680
protected function buildAttributes($attributes)
    {
        if ( ! $attributes) {
            return;
        }

        $attributeMap = [];
        foreach ($attributes as $attribute => $value) {
            $attributeMap[] = $attribute . '="' . $value . '"';
        }

        return implode($attributeMap, ' ');
    }
952796
public function toArray(array $attributes = array())
	{
		$data = parent::toArray();

		if(count($attributes) == 0)
			return $data;

		$new = array();

		foreach($attributes as $attribute)
			$new[$attribute] = $data[$attribute];

		return $new;
	}
1268900
public static function attributes(array $attributes = NULL)
    {
        if (!$attributes) return;

        asort($attributes);
        $h = '';
        foreach ($attributes as $k => $v) {
            $h .= " $k=\"" . self::h($v) . '"';
        }
        return $h;
    }
1289858
public function getHtml(array $attributes = []): string
    {
        if ($this->minimumValue !== null) {
            $attributes['min'] = $this->minimumValue;
        }

        if ($this->maximumValue !== null) {
            $attributes['max'] = $this->maximumValue;
        }

        return parent::getHtml($attributes);
    }
849573
protected static function attributes($attributes)
	{
		$html = array();

		// For numeric keys we will assume that the key and the value are the same
		// as this will convert HTML attributes such as "required" to a correct
		// form like required="required" instead of using incorrect numerics.
		foreach ((array) $attributes as $key => $value)
		{
			$element = null;

			if (is_numeric($key))
			{
				$key = $value;
			}

			if (!is_null($value))
			{
				$element = $key . '="' . htmlentities($value, ENT_COMPAT, 'UTF-8') . '"';
			}

			if (!is_null($element))
			{
				$html[] = $element;
			}
		}

		return count($html) > 0 ? ' ' . implode(' ', $html) : '';
	}
1113034
public function generateRules($attributes)
    {
        $rules = [];
        $safeAttributes = [];
        foreach ($attributes as $attribute) {
            if ($attribute == '_id') {
                continue;
            }
            $safeAttributes[] = $attribute;
        }
        if (!empty($safeAttributes)) {
            $rules[] = "[['" . implode("', '", $safeAttributes) . "'], 'safe']";
        }
        return $rules;
    }
576995
final public function overwriteAttributes($attributes)
    {
        foreach($attributes as $key => $attribute)
        {
            if (isset($this->{$key}))
            {
                $this->{$key} = $attribute;
            }
        }

        return $attributes;
    }
418918
public static function attributes(array $attributes): string
    {
        $html = [];
        foreach ($attributes as $key => $value) {
            if (is_string($value)) {
                $html[] = e($key) . '="' . e($value) . '"';
            } elseif (is_int($value)) {
                $html[] = e($key) . '="' . $value . '"';
            } elseif ($value !== false) {
                $html[] = e($key);
            }
        }

        return implode(' ', $html);
    }