private function formatItem( $item ) {

		$is_link  = isset( $item['url'] );
		$attr     = [];
		$esc_attr = '';

		// Add the anchor/span class attribute.
		$attr['class'] = sprintf(
			$this->args['anchor_class'],
			$is_link ? 'link' : $item['type']
		);

		// If this is a link, add the URL.
		if ( $is_link ) {
			$attr['href'] = $item['url'];
		}

		// If this is the current item, add the `aria-current` attribute.
		if ( 'current' === $item['type'] ) {
			$attr['aria-current'] = $this->args['aria_current'];
		}

		// Loop through the attributes and format them into a string.
		foreach ( $attr as $name => $value ) {

			$esc_attr .= sprintf(
				' %s="%s"',
				esc_html( $name ),
				'href' === $name ? esc_url( $value ) : esc_attr( $value )
			);
		}

		// Builds and formats the list item.
		return sprintf(
			'<%1$s class="%2$s"><%3$s %4$s>%5$s</%3$s></%1$s>',
			tag_escape( $this->args['item_tag'] ),
			esc_attr( sprintf( $this->args['item_class'], $item['type'] ) ),
			$is_link ? 'a' : 'span',
			trim( $esc_attr ),
			$item['content']
		);
	}