Passed
Push — master ( e51c9a...41921a )
by Chris
04:16
created

LSX_Schema_Graph_Piece::__construct()   A

Complexity

Conditions 6
Paths 2

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 7
nc 2
nop 1
dl 0
loc 8
rs 9.2222
c 0
b 0
f 0
1
<?php
2
/**
3
 * Schema for LSX
4
 *
5
 * @package lsx
6
 */
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line after the file comment
Loading history...
7
/**
8
 * Returns schema Review data.
9
 *
10
 * @since 10.2
11
 */
12
if ( interface_exists( 'WPSEO_Graph_Piece' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
13
14
	class LSX_Schema_Graph_Piece implements WPSEO_Graph_Piece {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for class LSX_Schema_Graph_Piece
Loading history...
15
		/**
16
		 * A value object with context variables.
17
		 *
18
		 * @var \WPSEO_Schema_Context
19
		 */
20
		public $context;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
21
		/**
22
		 * This is the post type that you want the piece to output for.
23
		 *
24
		 * @var string;
25
		 */
26
		public $post_type;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before member var; 0 found
Loading history...
27
		/**
28
		 * If this is a top level parent
29
		 *
30
		 * @var boolean
31
		 */
32
		public $is_top_level;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before member var; 0 found
Loading history...
33
		/**
34
		 * This holds the meta_key => scehma_type of the fields you want to add to your subtrip.
35
		 *
36
		 * @var array()
37
		 */
38
		public $place_ids;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before member var; 0 found
Loading history...
39
		/**
40
		 * This holds an object or the current trip post.
41
		 *
42
		 * @var WP_Post();
43
		 */
44
		public $post;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before member var; 0 found
Loading history...
45
		/**
46
		 * This holds URL for the trip
47
		 *
48
		 * @var string
49
		 */
50
		public $post_url;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before member var; 0 found
Loading history...
51
		/**
52
		 * Constructor.
53
		 *
54
		 * @param \WPSEO_Schema_Context $context A value object with context variables.
55
		 */
56
		public function __construct( WPSEO_Schema_Context $context ) {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
57
			$this->context      = $context;
58
			$this->place_ids    = array();
59
			$this->post         = get_post( $this->context->id );
0 ignored issues
show
Bug introduced by
$this->context->id of type string is incompatible with the type WP_Post|integer|null expected by parameter $post of get_post(). ( Ignorable by Annotation )

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

59
			$this->post         = get_post( /** @scrutinizer ignore-type */ $this->context->id );
Loading history...
60
			$this->post_url     = get_permalink( $this->context->id );
0 ignored issues
show
Documentation Bug introduced by
It seems like get_permalink($this->context->id) can also be of type false. However, the property $post_url is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
Bug introduced by
$this->context->id of type string is incompatible with the type WP_Post|integer expected by parameter $post of get_permalink(). ( Ignorable by Annotation )

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

60
			$this->post_url     = get_permalink( /** @scrutinizer ignore-type */ $this->context->id );
Loading history...
61
			$this->is_top_level = false;
62
			if ( is_object( $this->post ) && isset( $this->post->post_parent ) && ( false === $this->post->post_parent || 0 === $this->post->post_parent || '' === $this->post->post_parent ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
63
				$this->is_top_level = true;
64
			}
65
		}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
66
		/**
67
		 * Determines whether or not a piece should be added to the graph.
68
		 *
69
		 * @return bool
70
		 */
71
		public function is_needed() {
72
			if ( ! is_singular() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
73
				return false;
74
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
75
			if ( false === $this->context->site_represents ) {
0 ignored issues
show
introduced by
The condition false === $this->context->site_represents is always false.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
76
				return false;
77
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
78
			return LSX_Schema_Utils::is_type( get_post_type(), $this->post_type );
79
		}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
80
		/**
81
		 * Returns Review data.
82
		 *
83
		 * @return array $data Review data.
84
		 */
85
		public function generate() {
86
			$data = array();
87
			return $data;
88
		}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
89
		/**
90
		 * Gets the connected reviews post type and set it as the "Review" schema
91
		 *
92
		 * @param  array    $data An array of offers already added.
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 4 found
Loading history...
93
		 * @param  string   $data_key
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 3 found
Loading history...
94
		 * @param  boolean  $include_aggregate
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
95
		 * @return array    $data
96
		 */
97
		public function add_reviews( $data, $data_key = 'reviews', $include_aggregate = true ) {
98
			$reviews       = get_post_meta( $this->context->id, 'review_to_' . $this->post_type, false );
0 ignored issues
show
Bug introduced by
$this->context->id of type string is incompatible with the type integer expected by parameter $post_id of get_post_meta(). ( Ignorable by Annotation )

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

98
			$reviews       = get_post_meta( /** @scrutinizer ignore-type */ $this->context->id, 'review_to_' . $this->post_type, false );
Loading history...
99
			$reviews_array = array();
100
			if ( ! empty( $reviews ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
101
				$aggregate_value = 1;
102
				$review_count    = 0;
103
				foreach ( $reviews as $review_id ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
104
					$rating      = get_post_meta( $review_id, 'rating', true );
105
					$author      = get_post_meta( $review_id, 'reviewer_name', true );
106
					$description = wp_strip_all_tags( get_the_excerpt( $review_id ) );
107
					$review_args = array(
108
						'author'     => $author,
109
						'reviewBody' => $description,
110
					);
111
					// Add in the review rating.
112
					if ( false !== $rating && '' !== $rating && '0' !== $rating && 0 !== $rating ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
113
						$review_args['reviewRating'] = array(
114
							'@type'       => 'Rating',
115
							'ratingValue' => $rating,
116
						);
117
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
118
					$reviews_array = LSX_Schema_Utils::add_review( $reviews_array, $review_id, $this->context, $review_args );
0 ignored issues
show
Bug introduced by
The method add_review() does not exist on LSX_Schema_Utils. ( Ignorable by Annotation )

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

118
					/** @scrutinizer ignore-call */ 
119
     $reviews_array = LSX_Schema_Utils::add_review( $reviews_array, $review_id, $this->context, $review_args );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
119
					$review_count++;
120
				}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
121
				if ( ! empty( $reviews_array ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
122
					if ( true === $include_aggregate ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
123
						$data['aggregateRating'] = array(
124
							'@type'       => 'AggregateRating',
125
							'ratingValue' => (string) $aggregate_value,
126
							'reviewCount' => (string) $review_count,
127
							'bestRating'  => '5',
128
							'worstRating' => '1',
129
						);
130
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
131
					$data[ $data_key ] = $reviews_array;
132
				}
133
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
134
			return $data;
135
		}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
136
		/**
137
		 * Gets the connected posts and set it as the "Article" schema
138
		 *
139
		 * @param  array  $data An array of offers already added.
140
		 * @param  string $data_key
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
141
		 * @return array  $data
142
		 */
143
		public function add_articles( $data, $data_key = 'subjectOf' ) {
144
			$posts       = get_post_meta( $this->context->id, 'post_to_' . $this->post_type, false );
0 ignored issues
show
Bug introduced by
$this->context->id of type string is incompatible with the type integer expected by parameter $post_id of get_post_meta(). ( Ignorable by Annotation )

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

144
			$posts       = get_post_meta( /** @scrutinizer ignore-type */ $this->context->id, 'post_to_' . $this->post_type, false );
Loading history...
145
			$posts_array = array();
146
			if ( ! empty( $posts ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
147
				foreach ( $posts as $post_id ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
148
					$post_args = array(
149
						'articleBody' => wp_strip_all_tags( get_the_excerpt( $post_id ) ),
150
						'headline'    => get_the_title( $post_id ),
151
					);
152
					$section   = get_the_term_list( $post_id, 'category' );
153
					if ( ! is_wp_error( $section ) && '' !== $section && false !== $section ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
154
						$post_args['articleSection'] = wp_strip_all_tags( $section );
0 ignored issues
show
Bug introduced by
It seems like $section can also be of type WP_Error; however, parameter $string of wp_strip_all_tags() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

154
						$post_args['articleSection'] = wp_strip_all_tags( /** @scrutinizer ignore-type */ $section );
Loading history...
155
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
156
					if ( $this->context->site_represents_reference ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
157
						$post_args['publisher'] = $this->context->site_represents_reference;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->context->site_represents_reference can also be of type true. However, the property $site_represents_reference is declared as type array|false. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
158
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
159
					$image_url = get_the_post_thumbnail_url( $post_id, 'lsx-thumbnail-wide' );
160
					if ( false !== $image_url ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
161
						$post_args['image'] = $image_url;
162
					}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
163
					$posts_array = LSX_Schema_Utils::add_article( $posts_array, $post_id, $this->context, $post_args );
0 ignored issues
show
Bug introduced by
The method add_article() does not exist on LSX_Schema_Utils. ( Ignorable by Annotation )

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

163
					/** @scrutinizer ignore-call */ 
164
     $posts_array = LSX_Schema_Utils::add_article( $posts_array, $post_id, $this->context, $post_args );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
164
				}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
165
				if ( ! empty( $posts_array ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
166
					$data[ $data_key ] = $posts_array;
167
				}
168
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
169
			return $data;
170
		}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
171
		/**
172
		 * Adds the Project and Testimonials attached to the Team Member
173
		 *
174
		 * @param array $data
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
175
		 *
176
		 * @return array $data
177
		 */
178
		public function add_connections( $data ) {
179
			$connections_array = array();
180
			if ( $this->is_top_level ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
181
				$connections_array = $this->add_regions( $connections_array );
0 ignored issues
show
Bug introduced by
The method add_regions() does not exist on LSX_Schema_Graph_Piece. Did you maybe mean add_reviews()? ( Ignorable by Annotation )

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

181
				/** @scrutinizer ignore-call */ 
182
    $connections_array = $this->add_regions( $connections_array );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
182
				$connections_array = $this->add_accommodation( $connections_array );
0 ignored issues
show
Bug introduced by
The method add_accommodation() does not exist on LSX_Schema_Graph_Piece. ( Ignorable by Annotation )

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

182
				/** @scrutinizer ignore-call */ 
183
    $connections_array = $this->add_accommodation( $connections_array );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
183
				if ( ! empty( $connections_array ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
184
					$data['containsPlace'] = $connections_array;
185
				}
186
			} else {
187
				$connections_array             = $this->add_countries( $connections_array );
0 ignored issues
show
Bug introduced by
The method add_countries() does not exist on LSX_Schema_Graph_Piece. ( Ignorable by Annotation )

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

187
				/** @scrutinizer ignore-call */ 
188
    $connections_array             = $this->add_countries( $connections_array );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 13 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
188
				$data['containedInPlace'] = $connections_array;
189
				$connections_array          = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 10 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
190
				$connections_array          = $this->add_accommodation( $connections_array );
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 10 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
191
				$data['containsPlace'] = $connections_array;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
192
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
193
			return $data;
194
		}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
195
		/**
196
		 * Adds the terms for the taxonomy
197
		 *
198
		 * @param array $data     Review data.
199
		 * @param array $data_key the parameter name you wish to assign it to.
200
		 * @param array $taxonomy the taxonomy to grab terms for.
201
		 *
202
		 * @return array $data Review data.
203
		 */
204
		public function add_taxonomy_terms( $data, $data_key, $taxonomy ) {
205
			/**
206
			 * Filter: 'lsx_schema_' . $this->post_type . '_' . $data_key . '_taxonomy' - Allow changing the taxonomy used to assign keywords to a post type Review data.
207
			 *
208
			 * @api string $taxonomy The chosen taxonomy.
209
			 */
210
			$taxonomy = apply_filters( 'lsx_schema_' . $this->post_type . '_' . $data_key . '_taxonomy', $taxonomy );
0 ignored issues
show
Bug introduced by
Are you sure $data_key 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

210
			$taxonomy = apply_filters( 'lsx_schema_' . $this->post_type . '_' . /** @scrutinizer ignore-type */ $data_key . '_taxonomy', $taxonomy );
Loading history...
211
			return LSX_Schema_Utils::add_terms( $data, $this->context->id, $data_key, $taxonomy );
0 ignored issues
show
Bug introduced by
$data_key of type array is incompatible with the type string expected by parameter $key of LSX_Schema_Utils::add_terms(). ( Ignorable by Annotation )

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

211
			return LSX_Schema_Utils::add_terms( $data, $this->context->id, /** @scrutinizer ignore-type */ $data_key, $taxonomy );
Loading history...
Bug introduced by
It seems like $taxonomy can also be of type array; however, parameter $taxonomy of LSX_Schema_Utils::add_terms() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

211
			return LSX_Schema_Utils::add_terms( $data, $this->context->id, $data_key, /** @scrutinizer ignore-type */ $taxonomy );
Loading history...
212
		}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
213
		/**
214
		 * Adds the custom field value for the supplied key
215
		 *
216
		 * @param array   $data     Schema data.
217
		 * @param string  $data_key the parameter name you wish to assign it to.
218
		 * @param string  $meta_key the taxonomy to grab terms for.
219
		 * @param boolean $single   A single custom field or an array
0 ignored issues
show
Coding Style Documentation introduced by
Parameter comment must end with a full stop
Loading history...
220
		 *
221
		 * @return array $data Review data.
222
		 */
223
		public function add_custom_field( $data, $data_key, $meta_key, $single = true ) {
224
			$value = get_post_meta( $this->context->id, $meta_key, $single );
0 ignored issues
show
Bug introduced by
$this->context->id of type string is incompatible with the type integer expected by parameter $post_id of get_post_meta(). ( Ignorable by Annotation )

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

224
			$value = get_post_meta( /** @scrutinizer ignore-type */ $this->context->id, $meta_key, $single );
Loading history...
225
			if ( '' !== $value && false !== $value ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
226
				$data[ $data_key ] = $value;
227
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
228
			return $data;
229
		}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
230
	}
231
}
232