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

Jetpack_Sitemap_Buffer_Video::get_root_element()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 37
Code Lines 15

Duplication

Lines 37
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 15
nc 2
nop 0
dl 37
loc 37
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_Video
5
 * extends the Jetpack_Sitemap_Buffer class to represent the single video sitemap
6
 * buffer.
7
 *
8
 * @since 5.3.0
9
 * @package Jetpack
10
 */
11
12
/**
13
 * A buffer for constructing sitemap video xml files for users without libxml support.
14
 *
15
 * @since 5.3.0
16
 */
17 View Code Duplication
class Jetpack_Sitemap_Buffer_Video 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 XML namespaces included in video sitemaps.
24
			 *
25
			 * @module sitemaps
26
			 *
27
			 * @since 4.8.0
28
			 *
29
			 * @param array $namespaces Associative array with namespaces and namespace URIs.
30
			 */
31
			$namespaces = apply_filters(
32
				'jetpack_sitemap_video_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
					'xmlns:video'        => 'http://www.google.com/schemas/sitemap-video/1.1',
38
				)
39
			);
40
41
			$video_sitemap_xsl_url = $this->finder->construct_sitemap_url( 'video-sitemap.xsl' );
42
			$jetpack_version = JETPACK__VERSION;
43
44
			$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...
45
				"<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL
46
				. "<?xml-stylesheet type='text/xsl' href='{$video_sitemap_xsl_url}'?>" . PHP_EOL
47
				. '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>',
48
				'</urlset>'
49
			);
50
51
			$this->byte_capacity -= strlen( join( '', $this->root ) );
52
		}
53
54
		return $this->root;
55
	}
56
}
57