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

BotDetector::handleRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 2
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
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