Completed
Branch FET/11174/bot-detection-middle... (17f260)
by
unknown
93:18 queued 82:13
created

BotDetector   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 23
rs 10
c 1
b 0
f 0
wmc 1
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle_request() 0 11 1
1
<?php
2
3
namespace EventEspresso\core\services\request_stack\middleware;
4
5
use EE_Request;
6
use EE_Response;
7
use EventEspressoVendor\Jaybizzle\CrawlerDetect\CrawlerDetect;
8
9
defined('EVENT_ESPRESSO_VERSION') || exit;
10
11
12
13
/**
14
 * Class BotDetector
15
 * attempts to determine if current user is a bot
16
 *
17
 * @package EventEspresso\core\services\request_stack\middleware
18
 * @author  Brent Christensen
19
 * @since   4.9.52
20
 */
21
class BotDetector extends Middleware
22
{
23
24
    /**
25
     * converts a Request to a Response
26
     *
27
     * @param    EE_Request  $request
28
     * @param    EE_Response $response
29
     * @return    EE_Response
30
     */
31
    public function handle_request(EE_Request $request, EE_Response $response)
32
    {
33
        $this->request  = $request;
34
        $this->response = $response;
35
        $CrawlerDetect = new CrawlerDetect;
36
        // Check and record the user agent of the current 'visitor'
37
        $this->request->setIsBot($CrawlerDetect->isCrawler());
38
        $this->request->setUserAgent($CrawlerDetect->userAgent());
39
        $this->response = $this->process_request_stack($this->request, $this->response);
40
        return $this->response;
41
    }
42
43
}
44
// Location: BotDetector.php
45