Clean attribute value before required change.

@param string $name
@param mixed  $value

@return array
4698
private function manipulateAttribute($name, $value)
    {
        $current_value = array_get($this->attribute, $name, '');
        $separator = (strlen(trim($current_value)) > 0) ? $this->getAttributeValueSeparator($name) : '';
        $current_value = $separator !== '' ? explode($separator, $current_value) : [$current_value];

        if ($name == 'class' || $name == 'style') {
            $value = is_array($value) ? $value : [$value];
            $current_value = array_diff($current_value, $value);
        }

        return [$current_value, $separator];
    }
564947
public function attr($name, $value = null)
    {
        if ($value === null) {
            return $this->getAttribute($name);
        }

        return $this->setAttribute($name, $value);
    }
357969
public function assignAttribute($name, $value)
	{
		$table = static::table();
		if (!is_object($value)) {
			if (array_key_exists($name, $table->columns)) {
				$value = $table->columns[$name]->cast($value, static::connection());
			} else {
				$col = $table->getColumnByInflectedName($name);
				if (!is_null($col)){
					$value = $col->cast($value, static::connection());
				}
			}
		}

		// convert php's \DateTime to ours
		if ($value instanceof \DateTime) {
			$value = new DateTime($value->format('Y-m-d H:i:s T'));
		}

		// make sure DateTime values know what model they belong to so
		// dirty stuff works when calling set methods on the DateTime object
		if ($value instanceof DateTime) {
			$value->attributeOf($this, $name);
		}

		$this->_attributes[$name] = $value;
		$this->flagDirty($name);
		return $value;
	}
203296
public function filterValues($name, $value)
    {
        return $this->filter(function (EntityInterface $entity) use ($name, $value) {
            return $entity->getByName($name) === $value;
        });
    }
725217
protected function setAttributeType($name, $value)
    {

        if (array_key_exists($name, $this->casts)) {
            if (in_array($this->casts[$name], $this->castTypes)) {
                settype($value, $this->casts[$name]);
            }
        }

        return $value;
    }
299766
public function attr($name, $value = null)
    {
        if (func_num_args() < 2) {
            return @$this->attributes[$name];
        } else {
            if (is_null($value)) {
                unset($this->attributes[$name]);
            } else {
                $this->attributes[$name] = $value;
            }
            return $this;
        }
    }
314451
protected function cleanValue($value)
	{
		if (is_array($value)) {
			return array_map(function ($v) {
				return $this->cleanValue($v);
			}, $value);
		} else {
			return stripslashes($value);
		}
	}
920671
public function set($name, $value)
    {
        if ( !$value ) {
            $this->attributes->remove($name);

            return $this;
        }
        $this->attributes->set($name, $value);

        return $this;
    }
2282
public function addToAttribute($name, $value)
    {
        $attr = $this->getAttribute($name);
        $this->setAttribute($name, $attr . $value);

        return $this;
    }
359996
public static function delete( $name = '', $value = '' ) {

		if ( ! empty( $value ) ) {
			$GLOBALS['_DELETE'][ $name ] = $value;
		}

		if ( empty( $name ) ) {
			return ( isset( $GLOBALS['_DELETE'] ) ) ? $GLOBALS['_DELETE'] : NULL;
		} else {
			return ( isset( $GLOBALS['_DELETE'][ $name ] ) ) ? $GLOBALS['_DELETE'][ $name ] : NULL;
		}

	}
1304850
public function createNew(
        string $attribute,
        string $name,
        float $value
    ) : array {
        return $this->sendPost(
            sprintf('/profiles/%s/scores', $this->userName),
            [],
            [
                'attribute' => $attribute,
                'name'      => $name,
                'value'     => $value
            ]
        );
    }
171286
public function prependAttribute($name, ...$value)
    {
        list($current_value, $separator) = $this->manipulateAttribute($name, $value);

        foreach ($value as $attribute_value) {
            array_unshift($current_value, $attribute_value);
        }

        $this->updateAttribute($name, $current_value, $separator);

        return $this;
    }
819986
public function appendAttribute($name, $value, $option = TRUE)
	{
		if (is_array($value)) {
			$prev = isset($this->attrs[$name]) ? (array)$this->attrs[$name] : [];
			$this->attrs[$name] = $value + $prev;

		} elseif ((string)$value === '') {
			$tmp = &$this->attrs[$name]; // appending empty value? -> ignore, but ensure it exists

		} elseif (!isset($this->attrs[$name]) || is_array($this->attrs[$name])) { // needs array
			$this->attrs[$name][$value] = $option;

		} else {
			$this->attrs[$name] = [$this->attrs[$name] => TRUE, $value => $option];
		}

		return $this;
	}
1253091
private static function getHtmlAttribute(string $name, $value): string
    {
        if (!self::isset($value)) {
            return '';
        }

        if ($value === true) {
            return $name;
        }

        if (is_array($value)) {
            $value = self::convertAttributeArrayValue($name, $value);
        }

        return sprintf('%s="%s"', $name, static::escape((string) $value));
    }
448445
public function setAttribute($name, $value = null)
    {
        if (is_array($name)) {
            foreach ($name as $k => $v) {
                $this->attributes[$k] = $v;
            }
        } else {
            $this->attributes[$name] = $value;
        }
    }
547987
public function addAttr($name, $value)
    {
        $name = trim($name);
        $value = trim($value);

        if ($value && !$this->existsAttr($name)) {
            $this->attrs[$name] = $value;
        }

        return $this;
    }
1089710
public function attribute($name, $value=null)
    {
        if ($value === null) {
            unset($this->_attributes[$name]);
        } else {
            $this->_attributes[$name] = $value;
        }
    }