Completed
Push — master ( 7ca08e...5a5cfd )
by Matt
02:19
created

CommentCheckResult::isBlatantSpam()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 1
nc 3
nop 0
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Gothick\AkismetClient\Result;
3
4
/**
5
 * Result of calling the client-check method on the Akismet API.
6
 * @author matt
7
 *
8
 */
9
class CommentCheckResult extends ClientResult
10
{
11
	/**
12
	 * Create a result; throws if the result body isn't in the known list of responses.
13
	 * @param \GuzzleHttp\Psr7\Response $response
14
	 */
15 15
	public function __construct(\GuzzleHttp\Psr7\Response $response)
16
	{
17 15
		parent::__construct($response, [ 'true', 'false' ]);
18 13
	}
19
20
	/**
21
	 * Does Akismet think the comment is spam?
22
	 * @return boolean
23
	 */
24 5
	public function isSpam() {
25 5
		return $this->raw_result == 'true';
26
	}
27
	/**
28
	 * Is the comment blatant spam which can definitely be discarded without
29
	 * human intervention? See https://blog.akismet.com/2014/04/23/theres-a-ninja-in-your-akismet/
30
	 *
31
	 * @return boolean
32
	 */
33 3
	public function isBlatantSpam() {
34 3
		return ($this->isSpam() && $this->hasProTip() && $this->getProTip() == 'discard');
35
	}
36
}