Kirki_Output_Field_Image   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B process_output() 0 24 7
1
<?php
2
/**
3
 * Handles CSS output for image fields.
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license    https://opensource.org/licenses/MIT
9
 * @since       3.0.10
10
 */
11
12
/**
13
 * Output overrides.
14
 */
15
class Kirki_Output_Field_Image extends Kirki_Output {
16
17
	/**
18
	 * Processes a single item from the `output` array.
19
	 *
20
	 * @access protected
21
	 * @param array $output The `output` item.
22
	 * @param array $value  The field's value.
23
	 */
24
	protected function process_output( $output, $value ) {
25
		if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) {
26
			return;
27
		}
28
		$output = wp_parse_args(
29
			$output, array(
0 ignored issues
show
Coding Style introduced by aristath
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
30
				'media_query' => 'global',
31
				'prefix'      => '',
32
				'units'       => '',
33
				'suffix'      => '',
34
			)
35
		);
36
		if ( is_array( $value ) ) {
0 ignored issues
show
introduced by Aristeides Stathopoulos
The condition is_array($value) is always true.
Loading history...
37
			if ( isset( $output['choice'] ) && $output['choice'] ) {
38
				$this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value[ $output['choice'] ] ) . $output['units'] . $output['suffix'];
0 ignored issues
show
Bug introduced by Aristeides Stathopoulos
Are you sure $this->process_property_...lue[$output['choice']]) of type array can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
				$this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . /** @scrutinizer ignore-type */ $this->process_property_value( $output['property'], $value[ $output['choice'] ] ) . $output['units'] . $output['suffix'];
Loading history...
39
				return;
40
			}
41
			if ( isset( $value['url'] ) ) {
42
				$this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value['url'] ) . $output['units'] . $output['suffix'];
0 ignored issues
show
Bug introduced by Aristeides Stathopoulos
Are you sure $this->process_property_...perty'], $value['url']) of type array can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
				$this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . /** @scrutinizer ignore-type */ $this->process_property_value( $output['property'], $value['url'] ) . $output['units'] . $output['suffix'];
Loading history...
43
				return;
44
			}
45
			return;
46
		}
47
		$this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix'];
48
	}
49
}
50