Passed
Push — master ( 035240...f758bd )
by Gabor
03:14
created

ServerRequest::isXmlHttpRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 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\Adapter\Http\GuzzleHttp;
15
16
use GuzzleHttp\Psr7\ServerRequest as GuzzleServerRequest;
17
use WebHemi\Adapter\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