Completed
Push — fix/nosara ( 09438e...93ba64 )
by
unknown
11:29
created

Jetpack_Sitemap_Buffer_Page::get_root_element()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 36
Code Lines 14

Duplication

Lines 36
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 14
nc 2
nop 0
dl 36
loc 36
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * Sitemaps (per the protocol) are essentially lists of XML fragments;
4
 * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Page
5
 * extends the Jetpack_Sitemap_Buffer class to represent the single page sitemap
6
 * buffer.
7
 *
8
 * @since 5.3.0
9
 * @package Jetpack
10
 */
11
12
/**
13
 * A buffer for constructing sitemap page xml files for users with no libxml support.
14
 *
15
 * @since 5.3.0
16
 */
17 View Code Duplication
class Jetpack_Sitemap_Buffer_Page extends Jetpack_Sitemap_Buffer_Fallback {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
19
	protected function get_root_element() {
20
		if ( ! isset( $this->root ) ) {
21
22
			/**
23
			 * Filter the attribute value pairs used for namespace and namespace URI mappings.
24
			 *
25
			 * @module sitemaps
26
			 *
27
			 * @since 3.9.0
28
			 *
29
			 * @param array $namespaces Associative array with namespaces and namespace URIs.
30
			 */
31
			$namespaces = apply_filters(
32
				'jetpack_sitemap_ns',
33
				array(
34
					'xmlns:xsi'          => 'http://www.w3.org/2001/XMLSchema-instance',
35
					'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
36
					'xmlns'              => 'http://www.sitemaps.org/schemas/sitemap/0.9',
37
				)
38
			);
39
40
			$jetpack_version = JETPACK__VERSION;
41
			$sitemap_xsl_url = $this->finder->construct_sitemap_url( 'sitemap.xsl' );
42
43
			$this->root = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array("<!-- generator='j...es) . '>', '</urlset>') of type array<integer,string,{"0":"string","1":"string"}> is incompatible with the declared type object<DOMElement> of property $root.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
44
				"<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL
45
				. "<?xml-stylesheet type='text/xsl' href='{$sitemap_xsl_url}'?>" . PHP_EOL
46
				. '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>',
47
				'</urlset>'
48
			);
49
50
			$this->byte_capacity -= strlen( join( '', $this->root ) );
51
		}
52
53
		return $this->root;
54
	}
55
}
56