Skip to content

Commit 7feb800

Browse files
committed
Revert to Request & Response interfaces
1 parent 7fc6593 commit 7feb800

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

application/Filters/Honeypot.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace App\Filters;
44

55
use CodeIgniter\Filters\FilterInterface;
6-
use CodeIgniter\HTTP\IncomingRequest;
7-
use CodeIgniter\HTTP\Response;
6+
use CodeIgniter\HTTP\RequestInterface;
7+
use CodeIgniter\HTTP\ResponseInterface;
88
use Config\Services;
99
use CodeIgniter\Honeypot\Exceptions\HoneypotException;
1010
use CodeIgniter\Honeypot\Honeypot;
@@ -16,11 +16,11 @@ class Honeypot implements FilterInterface
1616
* Checks if Honeypot field is empty; if not
1717
* then the requester is a bot
1818
*
19-
* @param CodeIgniter\HTTP\IncomingRequest $request
19+
* @param CodeIgniter\HTTP\RequestInterface $request
2020
*
2121
* @return mixed
2222
*/
23-
public function before(IncomingRequest $request)
23+
public function before(RequestInterface $request)
2424
{
2525
$honeypot = new Honeypot(new \Config\Honeypot());
2626
if ($honeypot->hasContent($request))
@@ -32,11 +32,11 @@ public function before(IncomingRequest $request)
3232
/**
3333
* Attach a honypot to the current response.
3434
*
35-
* @param CodeIgniter\HTTP\IncomingRequest $request
36-
* @param CodeIgniter\HTTP\Response $response
35+
* @param CodeIgniter\HTTP\RequestInterface $request
36+
* @param CodeIgniter\HTTP\ResponseInterface $response
3737
* @return mixed
3838
*/
39-
public function after(IncomingRequest $request, Response $response)
39+
public function after(RequestInterface $request, ResponseInterface $response)
4040
{
4141
$honeypot = new Honeypot(new \Config\Honeypot());
4242
$honeypot->attachHoneypot($response);

system/Honeypot/Honeypot.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
* @filesource
3939
*/
4040
use CodeIgniter\Config\BaseConfig;
41-
use CodeIgniter\HTTP\IncomingRequest;
42-
use CodeIgniter\HTTP\Response;
41+
use CodeIgniter\HTTP\RequestInterface;
42+
use CodeIgniter\HTTP\ResponseInterface;
4343
use CodeIgniter\Honeypot\Exceptions\HoneypotException;
4444

4545
class Honeypot
@@ -77,20 +77,20 @@ function __construct(BaseConfig $config)
7777
/**
7878
* Checks the request if honeypot field has data.
7979
*
80-
* @param \CodeIgniter\HTTP\IncomingRequest $request
80+
* @param \CodeIgniter\HTTP\RequestInterface $request
8181
*
8282
*/
83-
public function hasContent(IncomingRequest $request)
83+
public function hasContent(RequestInterface $request)
8484
{
8585
return ( ! empty($request->getPost($this->config->name))) ? true : false;
8686
}
8787

8888
/**
8989
* Attaches Honeypot template to response.
9090
*
91-
* @param \CodeIgniter\HTTP\Response $response
91+
* @param \CodeIgniter\HTTP\ResponseInterface $response
9292
*/
93-
public function attachHoneypot(Response $response)
93+
public function attachHoneypot(ResponseInterface $response)
9494
{
9595
$prep_field = $this->prepareTemplate($this->config->template);
9696

user_guide_src/source/libraries/honeypot.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Honeypot Class
55
The Honeypot Class makes it possible to determine when a Bot makes a request to a CodeIgniter4 application,
66
if it's enabled in ``Application\Config\Filters.php`` file. This is done by attaching form fields to any form,
77
and this form field is hidden from a human but accessible to a Bot. When data is entered into the field ,it's
8-
assumed the request is coming from a Bot, and you can thro a ``HoneypotException``.
8+
assumed the request is coming from a Bot, and you can throw a ``HoneypotException``.
99

1010
.. contents::
1111
:local:

0 commit comments

Comments
 (0)