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