1 | <?php namespace Arcanedev\SpamBlocker\Entities; |
||
13 | class Spammer implements Arrayable, Jsonable, JsonSerializable |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Properties |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | /** @var string */ |
||
21 | protected $host; |
||
22 | |||
23 | /** @var bool */ |
||
24 | protected $blocked; |
||
25 | |||
26 | /* ----------------------------------------------------------------- |
||
27 | | Constructor |
||
28 | | ----------------------------------------------------------------- |
||
29 | */ |
||
30 | |||
31 | /** |
||
32 | * Spammer constructor. |
||
33 | * |
||
34 | * @param string $host |
||
35 | * @param bool $blocked |
||
36 | */ |
||
37 | 120 | public function __construct($host, $blocked) |
|
42 | |||
43 | /* ----------------------------------------------------------------- |
||
44 | | Getters & Setters |
||
45 | | ----------------------------------------------------------------- |
||
46 | */ |
||
47 | |||
48 | /** |
||
49 | * Get the host url. |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | 117 | public function host() |
|
57 | |||
58 | /** |
||
59 | * Set the host url. |
||
60 | * |
||
61 | * @param string $host |
||
62 | * |
||
63 | * @return self |
||
64 | */ |
||
65 | 120 | public function setHost($host) |
|
71 | |||
72 | /** |
||
73 | * Get the blocked status. |
||
74 | * |
||
75 | * @return bool |
||
76 | */ |
||
77 | 57 | public function isBlocked() |
|
81 | |||
82 | /** |
||
83 | * Set the blocked status. |
||
84 | * |
||
85 | * @param bool $blocked |
||
86 | * |
||
87 | * @return self |
||
88 | */ |
||
89 | 120 | public function setBlocked($blocked) |
|
95 | |||
96 | /* ----------------------------------------------------------------- |
||
97 | | Main Methods |
||
98 | | ----------------------------------------------------------------- |
||
99 | */ |
||
100 | |||
101 | /** |
||
102 | * Make a spammer instance. |
||
103 | * |
||
104 | * @param string $host |
||
105 | * @param bool $blocked |
||
106 | * |
||
107 | * @return self |
||
108 | */ |
||
109 | 108 | public static function make($host, $blocked = true) |
|
113 | |||
114 | /** |
||
115 | * Check if the given host is the same as the spammer host. |
||
116 | * |
||
117 | * @param string $host |
||
118 | * |
||
119 | * @return bool |
||
120 | */ |
||
121 | 3 | public function isSameHost($host) |
|
125 | |||
126 | /* ----------------------------------------------------------------- |
||
127 | | Other Methods |
||
128 | | ----------------------------------------------------------------- |
||
129 | */ |
||
130 | |||
131 | /** |
||
132 | * Get the instance as an array. |
||
133 | * |
||
134 | * @return array |
||
135 | */ |
||
136 | 6 | public function toArray() |
|
143 | |||
144 | /** |
||
145 | * Convert the object into something JSON serializable. |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | 3 | public function jsonSerialize() |
|
153 | |||
154 | /** |
||
155 | * Convert the object to its JSON representation. |
||
156 | * |
||
157 | * @param int $options |
||
158 | * |
||
159 | * @return string |
||
160 | */ |
||
161 | 3 | public function toJson($options = 0) |
|
165 | } |
||
166 |