Generate and set the model attributes.

@param object $model The model instance.
@param array  $attr  The model attributes.

@return void
13341
protected function generate($model, array $attr = [])
    {
        foreach ($attr as $key => $kind) {
            $value = $this->factory->generate($kind, $model, $this);

            $setter = 'set'.ucfirst(static::camelize($key));

            // check if there is a setter and use it instead
            if (method_exists($model, $setter) && is_callable([$model, $setter])) {
                $model->$setter($value);
            } else {
                $model->$key = $value;
            }
        }
    }
384889
protected function addAttrRecurses($key, array $attr)
    {
        if (isset($this->form[ $key ])) {
            $this->form[ $key ][ 'attr' ] = $this->merge_attr($this->form[ $key ][ 'attr' ], $attr);

            return true;
        }

        foreach ($this->form as $input) {
            if ($input[ 'type' ] != 'group') {
                continue;
            }

            if ($input[ 'subform' ]->addAttrRecurses($key, $attr)) {
                return true;
            }
        }

        return false;
    }
203606
function _setAttributes(el, attrs) {
  Object.keys(attrs).forEach((key) => {
    el.setAttribute(key, attrs[key]);
  });
}
246257
protected function inputStartHandler(array $attrs): void
    {
        $this->text  = '';
        $this->input = [
            'name'    => $attrs['name'] ?? '',
            'type'    => $attrs['type'] ?? '',
            'lookup'  => $attrs['lookup'] ?? '',
            'options' => $attrs['options'] ?? '',
            'default' => '',
            'value'   => '',
        ];

        if (isset($attrs['default'])) {
            if ($attrs['default'] === 'NOW') {
                $this->input['default'] = Carbon::now()->format('d M Y');
            } else {
                $match = [];
                if (preg_match('/NOW([+\-]\d+)/', $attrs['default'], $match) > 0) {
                    $this->input['default'] = Carbon::now()->addDays((int) $match[1])->format('d M Y');
                } else {
                    $this->input['default'] = $attrs['default'];
                }
            }
        } elseif ($attrs['name'] === 'pageSize') {
            $this->input['default'] = app(LocaleInterface::class)->territory()->paperSize();
        }
    }
1030619
public function addAttributes(array $attr)
    {
        foreach ($attr as $name => $value) {
            $this->setAttribute($name, $value);
        }

        return $this;
    }
753619
public function setStyleAttributeValue($attr_key, $attr_value): void
    {

        $style_array = $this->getStyleAttributeArray();
        $style_array[$attr_key] = $attr_value;

        $style_string = '';
        foreach ($style_array as $key => $value) {
            $style_string .= $key . ':' . $value . ';';
        }

        $this->setAttribute('style', $style_string);
    }
403520
protected function addValidAttributes( $attrs ) {
        foreach( $attrs as $attr ) {
            //add if string
            if( is_string( $attr ) ) {
                $this->validAttributes[] = $attr;
            }
        }
    }
118996
def setAttribute(self, attr: str, value: _AttrValueType) -> None:
        """"""
        self._set_attribute(attr, value)
1105009
public function setter($attr)
    {
        if (isset($this->_setters[$attr])) {
            return $this->_setters[$attr];
        } elseif (isset($this->_props[$attr])) {
            return $this->_props[$attr]->setter($attr);
        } elseif (isset($this->_rels[$attr])) {
            return $this->_rels[$attr]->setter($attr);
        }

        throw new Exception("No setter available for $attr");
    }
1225678
public function copyForUpdateFrom( $model, $attributes = [] ) {

		foreach ( $attributes as $attribute ) {

			if( $this->hasAttribute( $attribute ) ) {

				$this->setAttribute( $attribute, $model->$attribute );
			}
			else {

				$this->$attribute = $model->$attribute;
			}
		}
	}
27942
public function hasAttribute($attr)
    {
        if (isset($this->_setters[$attr])) {
            return true;
        } elseif (isset($this->_props[$attr])) {
            return true;
        } elseif (isset($this->_rels[$attr])) {
            return true;
        }

        return false;
    }
647436
protected function _buildAttribute($attr)
    {
        $string = array();

        foreach ($attr as $key => $value) {
            if (is_array($value)) {
                $value = implode(' ', $value);
            }

            $string[] = $key.'="'.$value.'"';
        }

        return implode(' ', $string);
    }
200436
public function setAttribute( $attr, $val )
    {
        $def = $this->definition();
        $fields = $def["fields"];
        $functions = isset( $def["set_functions"] ) ? $def["set_functions"] : null;
        if ( isset( $fields[$attr] ) )
        {
            $attrName = $fields[$attr];
            if ( is_array( $attrName ) )
            {
                $attrName = $attrName['name'];
            }

            $oldValue = null;
            if ( isset( $this->$attrName ) )
                $oldValue = $this->$attrName;
            $this->$attrName = $val;
            if ( $oldValue === null ||
                 $oldValue !== $val )
                $this->setHasDirtyData( true );
        }
        else if ( isset( $functions[$attr] ) )
        {
            $functionName = $functions[$attr];
            $oldValue = $this->$functionName( $val );
            if ( $oldValue === null or $oldValue !== $val )
                $this->setHasDirtyData( true );
        }
        else
        {
            eZDebug::writeError( "Undefined attribute '$attr', cannot set",
                                 $def['class_name'] );
        }
    }
1002199
public function setRecursiveAttribute(ItemInterface $menu, array $attr)
    {
        $itemIterator = new RecursiveItemIterator($menu->getIterator());

        $iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($iterator as $menuItem) {
            /* @var ItemInterface $menuItem */
            $menuItem->setChildrenAttributes($attr);
        }
    }
436864
public function attr($attr) {
		if($this->domnode === null)
			return null;
		return $this->domnode->getAttribute($attr);
	}
1365203
public function validateAttribute($model, $attribute)
    {
        $this->_model = $model;
        $this->_attributeName = $attribute;
        $result = $this->validateValue($model->$attribute);
        if (!empty($result)) {
            $this->addError($model, $attribute, $result[0], $result[1]);
        }
    }
1106181
public function setElementsAttr($attr, $value) {
		foreach ($this->getElements() as $element) {
			if ($element instanceof Tag) {
				$element->setAttr($attr, $value);
			}
		}
		
		return $this;
	}