1 | <?php namespace Arcanedev\SpamBlocker\Entities; |
||
11 | class Spammers extends Collection |
||
12 | { |
||
13 | /* ------------------------------------------------------------------------------------------------ |
||
14 | | Main Functions |
||
15 | | ------------------------------------------------------------------------------------------------ |
||
16 | */ |
||
17 | /** |
||
18 | * Load the items. |
||
19 | * |
||
20 | * @param array $spammers |
||
21 | * |
||
22 | * @return self |
||
23 | */ |
||
24 | 261 | public static function load(array $spammers) |
|
28 | |||
29 | /** |
||
30 | * Add many hosts to the blacklist collection. |
||
31 | * |
||
32 | * @param array $includes |
||
33 | * |
||
34 | * @return self |
||
35 | */ |
||
36 | 270 | public function includes(array $includes) |
|
44 | |||
45 | /** |
||
46 | * Add many hosts to the whitelist collection. |
||
47 | * |
||
48 | * @param array $excludes |
||
49 | * |
||
50 | * @return self |
||
51 | */ |
||
52 | 81 | public function excludes(array $excludes) |
|
60 | |||
61 | /** |
||
62 | * Add a host to a blacklist collection. |
||
63 | * |
||
64 | * @param string $host |
||
65 | * |
||
66 | * @return self |
||
67 | */ |
||
68 | 297 | public function blockOne($host) |
|
74 | |||
75 | /** |
||
76 | * Add a host to a whitelist collection. |
||
77 | * |
||
78 | * @param string $host |
||
79 | * |
||
80 | * @return self |
||
81 | */ |
||
82 | 72 | public function allowOne($host) |
|
88 | |||
89 | /** |
||
90 | * Add a host to the collection. |
||
91 | * |
||
92 | * @param string $host |
||
93 | * @param bool $blocked |
||
94 | * |
||
95 | * @return self |
||
96 | */ |
||
97 | 315 | private function addOne($host, $blocked = true) |
|
105 | |||
106 | /** |
||
107 | * Update a host/spammer. |
||
108 | * |
||
109 | * @param string $host |
||
110 | * @param bool $blocked |
||
111 | * |
||
112 | * @return self |
||
113 | */ |
||
114 | 54 | private function updateOne($host, $blocked = true) |
|
126 | |||
127 | /** |
||
128 | * Get a spammer from the collection. |
||
129 | * |
||
130 | * @param string $host |
||
131 | * |
||
132 | * @return \Arcanedev\SpamBlocker\Entities\Spammer|null |
||
133 | */ |
||
134 | 90 | public function getOne($host) |
|
140 | |||
141 | /** |
||
142 | * Filter the spammer by the given hosts. |
||
143 | * |
||
144 | * @param array $hosts |
||
145 | * @param bool $strict |
||
146 | * |
||
147 | * @return self |
||
148 | */ |
||
149 | 72 | public function whereHostIn(array $hosts, $strict = false) |
|
157 | |||
158 | /** |
||
159 | * Get only the blocked spammers. |
||
160 | * |
||
161 | * @return self |
||
162 | */ |
||
163 | public function whereBlocked() |
||
169 | |||
170 | /** |
||
171 | * Check if a spammer exists in the collection. |
||
172 | * |
||
173 | * @param string $host |
||
174 | * |
||
175 | * @return bool |
||
176 | */ |
||
177 | 315 | public function exists($host) |
|
183 | |||
184 | /* ------------------------------------------------------------------------------------------------ |
||
185 | | Other Functions |
||
186 | | ------------------------------------------------------------------------------------------------ |
||
187 | */ |
||
188 | /** |
||
189 | * Sanitize the host url. |
||
190 | * |
||
191 | * @param string $host |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | 315 | private function sanitizeHost($host) |
|
199 | } |
||
200 |