Completed
Branch FET/11399/verify-paypal-creden... (c7ad03)
by
unknown
66:22 queued 52:43
created

BotDetector   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleRequest() 0 12 1
1
<?php
2
3
namespace EventEspresso\core\services\request\middleware;
4
5
use EventEspresso\core\services\request\RequestInterface;
6
use EventEspresso\core\services\request\ResponseInterface;
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\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 RequestInterface $request
28
     * @param ResponseInterface      $response
29
     * @return ResponseInterface
30
     */
31
    public function handleRequest(RequestInterface $request, ResponseInterface $response)
32
    {
33
        $this->request  = $request;
34
        $this->response = $response;
35
        /** @var CrawlerDetect $CrawlerDetect */
36
        $CrawlerDetect = $this->loader->getShared('EventEspressoVendor\Jaybizzle\CrawlerDetect\CrawlerDetect');
37
        // Check and record the user agent of the current 'visitor'
38
        $this->request->setIsBot($CrawlerDetect->isCrawler());
39
        $this->request->setUserAgent($CrawlerDetect->userAgent());
40
        $this->response = $this->processRequestStack($this->request, $this->response);
41
        return $this->response;
42
    }
43
44
}
45
// Location: BotDetector.php
46