Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
19 / 19 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
RuleCheckerFactory | |
100.00% |
19 / 19 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
newRuleChecker | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\AbuseFilter\Parser; |
4 | |
5 | use MediaWiki\Extension\AbuseFilter\KeywordsManager; |
6 | use MediaWiki\Extension\AbuseFilter\Variables\VariableHolder; |
7 | use MediaWiki\Extension\AbuseFilter\Variables\VariablesManager; |
8 | use MediaWiki\Language\Language; |
9 | use Psr\Log\LoggerInterface; |
10 | use Wikimedia\Equivset\Equivset; |
11 | use Wikimedia\ObjectCache\BagOStuff; |
12 | use Wikimedia\Stats\IBufferingStatsdDataFactory; |
13 | |
14 | class RuleCheckerFactory { |
15 | public const SERVICE_NAME = 'AbuseFilterRuleCheckerFactory'; |
16 | |
17 | /** @var Language */ |
18 | private $contLang; |
19 | |
20 | /** @var BagOStuff */ |
21 | private $cache; |
22 | |
23 | /** @var LoggerInterface */ |
24 | private $logger; |
25 | |
26 | /** @var KeywordsManager */ |
27 | private $keywordsManager; |
28 | |
29 | /** @var VariablesManager */ |
30 | private $varManager; |
31 | |
32 | /** @var IBufferingStatsdDataFactory */ |
33 | private $statsdDataFactory; |
34 | |
35 | /** @var Equivset */ |
36 | private $equivset; |
37 | |
38 | /** @var int */ |
39 | private $conditionsLimit; |
40 | |
41 | /** |
42 | * @param Language $contLang |
43 | * @param BagOStuff $cache |
44 | * @param LoggerInterface $logger |
45 | * @param KeywordsManager $keywordsManager |
46 | * @param VariablesManager $varManager |
47 | * @param IBufferingStatsdDataFactory $statsdDataFactory |
48 | * @param Equivset $equivset |
49 | * @param int $conditionsLimit |
50 | */ |
51 | public function __construct( |
52 | Language $contLang, |
53 | BagOStuff $cache, |
54 | LoggerInterface $logger, |
55 | KeywordsManager $keywordsManager, |
56 | VariablesManager $varManager, |
57 | IBufferingStatsdDataFactory $statsdDataFactory, |
58 | Equivset $equivset, |
59 | int $conditionsLimit |
60 | ) { |
61 | $this->contLang = $contLang; |
62 | $this->cache = $cache; |
63 | $this->logger = $logger; |
64 | $this->keywordsManager = $keywordsManager; |
65 | $this->varManager = $varManager; |
66 | $this->statsdDataFactory = $statsdDataFactory; |
67 | $this->equivset = $equivset; |
68 | $this->conditionsLimit = $conditionsLimit; |
69 | } |
70 | |
71 | /** |
72 | * @param VariableHolder|null $vars |
73 | * @return FilterEvaluator |
74 | */ |
75 | public function newRuleChecker( ?VariableHolder $vars = null ): FilterEvaluator { |
76 | return new FilterEvaluator( |
77 | $this->contLang, |
78 | $this->cache, |
79 | $this->logger, |
80 | $this->keywordsManager, |
81 | $this->varManager, |
82 | $this->statsdDataFactory, |
83 | $this->equivset, |
84 | $this->conditionsLimit, |
85 | $vars |
86 | ); |
87 | } |
88 | } |