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 | 58 | 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 | 60 | 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 | 18 | 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 | 66 | 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 | 16 | 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 | 70 | private function addOne($host, $blocked = true) |
|
106 | |||
107 | /** |
||
108 | * Update a host/spammer. |
||
109 | * |
||
110 | * @param string $host |
||
111 | * @param bool $blocked |
||
112 | * |
||
113 | * @return self |
||
114 | */ |
||
115 | 12 | private function updateOne($host, $blocked = true) |
|
127 | |||
128 | /** |
||
129 | * Get a spammer from the collection. |
||
130 | * |
||
131 | * @param string $host |
||
132 | * |
||
133 | * @return \Arcanedev\SpamBlocker\Entities\Spammer|null |
||
134 | */ |
||
135 | 20 | public function getOne($host) |
|
141 | |||
142 | /** |
||
143 | * Filter the spammer by the given hosts. |
||
144 | * |
||
145 | * @param array $hosts |
||
146 | * @param bool $strict |
||
147 | * |
||
148 | * @return self |
||
149 | */ |
||
150 | 16 | public function whereHostIn(array $hosts, $strict = false) |
|
158 | |||
159 | /** |
||
160 | * Get only the blocked spammers. |
||
161 | * |
||
162 | * @return self |
||
163 | */ |
||
164 | public function whereBlocked() |
||
170 | |||
171 | /** |
||
172 | * Check if a spammer exists in the collection. |
||
173 | * |
||
174 | * @param string $host |
||
175 | * |
||
176 | * @return bool |
||
177 | */ |
||
178 | 70 | public function exists($host) |
|
184 | |||
185 | /* ----------------------------------------------------------------- |
||
186 | | Other Methods |
||
187 | | ----------------------------------------------------------------- |
||
188 | */ |
||
189 | |||
190 | /** |
||
191 | * Sanitize the host url. |
||
192 | * |
||
193 | * @param string $host |
||
194 | * |
||
195 | * @return string |
||
196 | */ |
||
197 | 70 | private function sanitizeHost($host) |
|
201 | } |
||
202 |