-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpamManager.php
More file actions
75 lines (65 loc) · 1.67 KB
/
SpamManager.php
File metadata and controls
75 lines (65 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace Perform\SpamBundle;
use Perform\BaseBundle\DependencyInjection\LoopableServiceLocator;
use Perform\SpamBundle\Checker\CheckResult;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\FormInterface;
/**
* Check various objects for signs of spam.
*
* @author Glynn Forrest <me@glynnforrest.com>
**/
class SpamManager
{
protected $textCheckers;
protected $formCheckers;
protected $requestCheckers;
public function __construct(
LoopableServiceLocator $textCheckers,
LoopableServiceLocator $formCheckers,
LoopableServiceLocator $requestCheckers
) {
$this->textCheckers = $textCheckers;
$this->formCheckers = $formCheckers;
$this->requestCheckers = $requestCheckers;
}
/**
* @param string $text
*
* @return Result
*/
public function checkText($text)
{
$result = new CheckResult();
foreach ($this->textCheckers as $checker) {
$checker->checkText($result, $text);
}
return $result;
}
/**
* @param FormInterface $form
*
* @return Result
*/
public function checkForm(FormInterface $form)
{
$result = new CheckResult();
foreach ($this->formCheckers as $checker) {
$checker->checkForm($result, $form);
}
return $result;
}
/**
* @param Request $request
*
* @return Result
*/
public function checkRequest(Request $request)
{
$result = new CheckResult();
foreach ($this->requestCheckers as $checker) {
$checker->checkRequest($result, $request);
}
return $result;
}
}