Incapsula::detect()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 3
1
<?php
2
/**
3
 * This file is part of SHIELDFY Web Application Firewall Detector.
4
 * (c) 2016 SHIELDFY, All rights reserved.
5
 *
6
 * The code provided was developed by Matthias "Nihylum" Kaschubowski
7
 *
8
 * The applied license is stored at the root directory of this package.
9
 */
10
namespace Shieldfy\Firewall;
11
12
use Shieldfy\FirewallInterface;
13
14
/**
15
 * Incapsula Firewall Class.
16
 *
17
 * @package shieldfy.waf-detector
18
 *
19
 * @author  Matthias Kaschubowski <[email protected]>
20
 */
21
class Incapsula implements FirewallInterface
22
{
23
    /**
24
     * returns the name of the firewall.
25
     *
26
     * @return string
27
     */
28
    public function getName()
29
    {
30
        return 'Incapsula';
31
    }
32
33
    /**
34
     * detects whether the provided headers and body string does match the firewall identification rules or not.
35
     *
36
     * @param string[] $headers
37
     * @param string   $bodyString
38
     * @param string   $url
39
     *
40
     * @return bool
41
     */
42
    public function detect(array $headers, $bodyString, $url)
43
    {
44
        return array_key_exists('x-cdn', $headers) && strtolower($headers['x-cdn']) === 'incapsula';
45
    }
46
}
47