Code Duplication    Length = 11-19 lines in 2 locations

includes/content/JsonContent.php 2 locations

@@ 122-140 (lines=19) @@
119
	 * @param mixed $val
120
	 * @return string HTML.
121
	 */
122
	protected function rootValueTable( $val ) {
123
		if ( is_object( $val ) ) {
124
			return $this->objectTable( $val );
125
		}
126
127
		if ( is_array( $val ) ) {
128
			// Wrap arrays in another array so that they're visually boxed in a container.
129
			// Otherwise they are visually indistinguishable from a single value.
130
			return $this->arrayTable( [ $val ] );
131
		}
132
133
		return Html::rawElement( 'table', [ 'class' => 'mw-json mw-json-single-value' ],
134
			Html::rawElement( 'tbody', [],
135
				Html::rawElement( 'tr', [],
136
					Html::element( 'td', [], $this->primitiveValue( $val ) )
137
				)
138
			)
139
		);
140
	}
141
142
	/**
143
	 * Create HTML table representing a JSON object.
@@ 224-234 (lines=11) @@
221
	 * @param mixed $val
222
	 * @return string HTML.
223
	 */
224
	protected function valueCell( $val ) {
225
		if ( is_object( $val ) ) {
226
			return Html::rawElement( 'td', [], $this->objectTable( $val ) );
227
		}
228
229
		if ( is_array( $val ) ) {
230
			return Html::rawElement( 'td', [], $this->arrayTable( $val ) );
231
		}
232
233
		return Html::element( 'td', [ 'class' => 'value' ], $this->primitiveValue( $val ) );
234
	}
235
236
	/**
237
	 * Construct text representing a JSON primitive value.