Normalize input attributes

@return array|string
499766
public function input( array $args = [], $implode = false )
	{
		$this->filterInputType();

		$attributes = $this->parseAttributes( self::INPUT_ATTRIBUTES, $args );

		return $this->maybeImplode( $attributes, $implode );
	}
837146
protected function normalizeColumns(string $input): string
    {
        $result = [];
        foreach (explode(',', $input) as $column) {
            $result[] = $this->normalizeColumn($column);
        }

        return implode(', ', $result);
    }
532107
final public function sanitizedAttributes () : array
	{
        $dbObject 			= Database::getInstance();
		$cleanAttributes 	= [];
		foreach ($this->attributes() as $key => $value):
			if (isset($value))
				$cleanAttributes[$key] = $dbObject->escapeValue($value);
		endforeach;
		return $cleanAttributes;
	}
1271015
public function normalize()
	{
		$path = clone $this;
		$path->parts = [];
		foreach ($this->parts as $part) {
			if ($part === '..') {
				if (empty($path->parts) || count($path->parts) === 1 && $path->parts[0] === '') {
					$path->parts[] = $part;
				} else {
					array_pop($path->parts);
				}
			} else if ($part === '.' && $this->partCount > 1) {
				// pass
			} else {
				$path->parts[] = $part;
			}
		}
		if ($this->lastPart === '..' || $this->lastPart === '.') {
			$path->parts[] = '';
		}
		$path->setParts($path->parts);
		return $path;
	}
965932
public function normalize()
    {
        $url = $this->getMediaUrl($this->mediaType);

        return [
            'type'    => $this->mediaType,
            'content' => [
                'attachment' => [
                    'type'    => $this->mediaType,
                    'payload' => [
                        'url'         => $url,
                        'is_reusable' => true
                    ]
                ]
            ]
        ];
    }
304354
protected function normalizeCrs()
    {
        $type = $this->props['attribs']['type'];
        if (empty($this->props['options'])) {
            $this->props['options'] = array();
            if ($type == 'checkbox') {
                $this->props['options'][] = array(
                    'value' => 'on',
                    'label' => $this->props['label'],
                    'attribs' => $this->props['attribs'],
                );
                $this->props['label'] = null;
                unset($this->props['attribs']['value']);
            }
        }
        if ($type == 'checkbox' && $this->props['checkboxGroup'] === 'auto') {
            $this->props['checkboxGroup'] = \count($this->props['options']) > 1;
        }
        foreach ($this->props['options'] as $key => $option) {
            if (!\is_array($option)) {
                $this->props['options'][$key] = array(
                    'label' => $option,
                    'attribs' => array(
                        'value' => \is_string($key)
                            ? $key
                            : $option,
                    ),
                );
            } else {
                $option = $this->moveShortcuts($option);
                if (!isset($option['label']) && isset($option['attribs']['value'])) {
                    $option['label'] = $option['attribs']['value'];
                }
                $this->props['options'][$key] = $option;
            }
        }
        if (\in_array($type, array('checkbox','select')) && !isset($this->props['values'])) {
            /*
                values may be passed as an alternate way of specifying which values are checked/selected
                single checkbox:
                    passing 'value' is considered the option (not user supplied value) unless options array is non-empty
            */
            $this->props['values'] = isset($this->attribs['value'])
                ? (array) $this->attribs['value']
                : array();
            unset($this->attribs['value']);
        }
    }
1318490
public function normalize()
    {
        $data = $this->get();
        if (is_array($data)) {
            $data = implode($this->separator, $data);
        }
        $data = trim($data, $this->separator);
        if (!$data) {
            $data = null;
        }

        if (get_magic_quotes_gpc()) {
            $this->set(stripslashes($data));
        } else {
            $this->set($data);
        }

        return parent::normalize();
    }
932031
public function renderAttributes() : string
    {
        $pairs = array_map(function(string $value, string $key) {
            return sprintf('%s="%s"', helpers\e($key), helpers\e($value));
        }, $this->attributes, array_keys($this->attributes));

        return implode(' ', $pairs);
    }
515309
public function getAttributes()
    {
        $attributes = array(
            'type' => $this->getInputType(),
            'name' => $this->getName(),
            'value' => $this->Value(),
            'class' => $this->extraClass(),
            'id' => $this->ID(),
            'disabled' => $this->isDisabled(),
            'readonly' => $this->isReadonly(),
            'autofocus' => $this->isAutofocus()
        );

        if ($this->Required()) {
            $attributes['required'] = 'required';
            $attributes['aria-required'] = 'true';
        }

        $attributes = array_merge($attributes, $this->attributes);

        $this->extend('updateAttributes', $attributes);

        return $attributes;
    }
325301
public function attributes()
    {
        $attributes = [];
        foreach ($this->rules() as $rule) {
            $names = reset($rule);
            if (is_string($names)) {
                $names = [$names];
            }
            foreach ($names as $name) {
                if (substr_compare($name, '!', 0, 1) === 0) {
                    $name = mb_substr($name, 1);
                }
                $attributes[$name] = $name;
            }
        }

        return array_values($attributes);
    }
539910
private function normalizeAttributes($source, HtmlTokenizer $tokenizer)
    {
        $result = '';
        foreach ($tokenizer->parse($source) as $token) {
            if (empty($token[HtmlTokenizer::TOKEN_ATTRIBUTES])) {
                $result .= $tokenizer->compileToken($token);
                continue;
            }

            $attributes = [];
            foreach ($token[HtmlTokenizer::TOKEN_ATTRIBUTES] as $attribute => $value) {
                if (in_array($attribute, $this->options['attributes']['trim'])) {
                    $value = trim($value);
                }

                if (empty($value) && in_array($attribute, $this->options['attributes']['drop'])) {
                    //Empty value
                    continue;
                }

                $attributes[$attribute] = $value;
            }

            $token[HtmlTokenizer::TOKEN_ATTRIBUTES] = $attributes;
            $result .= $tokenizer->compileToken($token);
        }

        return $result;
    }
1045188
public static function normalize_feed( $input ) {
		$hcard = array();
		foreach ( $input['items'] as $key => $item ) {
			if ( self::is_type( $item, 'h-card' ) ) {
				$hcard = $item;
				unset( $input['items'][ $key ] );
				break;
			}
		}
		if ( 1 === count( $input['items'] ) ) {
			if ( self::has_prop( $input['items'][0], 'author' ) ) {
				$input['items'][0]['properties']['author'] = array( $hcard );
			}
			return $input;
		}
		return array(
			'items' => array(
				array(
					'type'       => array( 'h-feed' ),
					'properties' => array(
						'author' => array( $hcard ),
					),
					'children'   => $input['items'],
				),
			),
		);
	}
167248
public function attributesToArray()
    {
        $values = array_map(function ($attribute) {
            return $this->getTranslation($attribute, config('app.locale')) ?: null;
        }, $keys = $this->getTranslatableAttributes());

        return array_replace(parent::attributesToArray(), array_combine($keys, $values));
    }
887262
public static function normalize(&$input)
    {
        //==============================================================================
        //      Convert ArrayObjects To Simple Array
        if ($input instanceof ArrayObject) {
            $input = $input->getArrayCopy();
            //==============================================================================
            // Normalize Contents
            self::normalize($input);

        //==============================================================================
        // Normalize Array Contents
        } elseif (is_array($input)) {
            foreach ($input as &$value) {
                self::normalize($value);
            }

            //==============================================================================
        // Normalize Bool as Strings
        } elseif (is_bool($input)) {
            $input = $input ? '1' : '0';

        //==============================================================================
        // Normalize Numbers as Strings
        } elseif (is_numeric($input)) {
            $input = strval($input);
        }

        return $input;
    }
140308
public function normalize(): string {
        if (!$this->uri) {
            return '';
        }

        $path = $this->path ?: '/';
        $path = $this->removeDotSegments($path);
        $path = $this->decodeUnreservedCharacters($path);
        $path = $this->decodeReservedSubDelimiters($path);

        return $this->reconstitute(
            $this->scheme,
            $this->getAuthority(),
            $path,
            $this->query,
            $this->fragment
        );
    }
817711
protected function getAttributes()
    {
        libxml_use_internal_errors(true);
        $dom = new DOMDocument('1.0', 'UTF-8');
        $dom->resolveExternals = false;
        $dom->validateOnParse = true;
        $dom->preserveWhiteSpace = false;
        $dom->strictErrorChecking = true;
        $dom->recover = true;

        @$dom->loadHTML($this->normalize($this->html));

        $errors = array_filter(libxml_get_errors(), function (LibXMLError $error) {
            return in_array((int) $error->code, static::$ignoreErrors, true) === false;
        });

        libxml_clear_errors();

        return [
            'severenity' => static::$severenity,
            'counter' => count($errors),
            'errors' => $errors,
            'html' => $this->html,
        ];
    }
949669
protected function formatAttributes()
    {
        $this->attributes['class'] = implode(' ', $this->classes);

        $html = '';

        foreach ($this->attributes as $name => $value) {
            $html[] = "$name=\"$value\"";
        }

        return implode(' ', $html);
    }