Test Failed
Push — master ( 3b4aec...d6370d )
by Paul
03:25
created

Metaboxes::updateAssignedToPost()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 13
nc 5
nop 1
dl 0
loc 16
ccs 0
cts 14
cp 0
crap 30
rs 9.5222
c 0
b 0
f 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Controllers\EditorController;
4
5
use GeminiLabs\SiteReviews\Database\CountsManager;
6
use GeminiLabs\SiteReviews\Helper;
7
8
class Metaboxes
9
{
10
	/**
11
	 * @param int $postId
12
	 * @return void
13
	 */
14
	public function saveAssignedToMetabox( $postId )
15
	{
16
		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return;
17
		$assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' ));
18
		if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) {
19
			$review = glsr( ReviewManager::class )->single( get_post( $postId ));
20
			glsr( CountsManager::class )->decreasePostCounts( $review );
21
		}
22
		update_post_meta( $postId, 'assigned_to', $assignedTo );
23
	}
24
25
	/**
26
	 * @param int $postId
27
	 * @return mixed
28
	 */
29
	public function saveResponseMetabox( $postId )
30
	{
31
		if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return;
32
		$response = strval( glsr( Helper::class )->filterInput( 'response' ))c;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING on line 32 at column 71
Loading history...
33
		update_post_meta( $postId, 'response', trim( wp_kses( $response, [
34
			'a' => ['href' => [], 'title' => []],
35
			'em' => [],
36
			'strong' => [],
37
		])));
38
	}
39
}
40