Passed
Push — master ( 0d72e8...44be60 )
by Gabor
04:58
created

ServerRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 17
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isXmlHttpRequest() 0 9 2
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2017 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link      http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Http\ServiceAdapter\GuzzleHttp;
15
16
use GuzzleHttp\Psr7\ServerRequest as GuzzleServerRequest;
17
use WebHemi\Http\ServerRequestInterface;
18
19
/**
20
 * Class ServerRequest.
21
 */
22
class ServerRequest extends GuzzleServerRequest implements ServerRequestInterface
23
{
24
    /**
25
     * Checks if it is an XML HTTP Request (Ajax) or not.
26
     *
27
     * @return bool
28
     */
29 5
    public function isXmlHttpRequest() : bool
30
    {
31 5
        $serverParams = $this->getServerParams();
32
33
        return (
34 5
            isset($serverParams['HTTP_X_REQUESTED_WITH'])
35 5
            && $serverParams['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
36
        );
37
    }
38
}
39