CommentCheckResult   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isSpam() 0 2 1
A isBlatantSpam() 0 2 3
A __construct() 0 3 1
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
	}
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
}