Completed
Push — master ( 3ab156...6d4a89 )
by Florian
05:03 queued 10s
created

RemoteAddress::useHttpXForwarded()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2016 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Model\Environment;
28
29
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress as CoreRemoteAddress;
30
31
/**
32
 * Extended RemoteAddress class
33
 */
34
class RemoteAddress extends CoreRemoteAddress
35
{
36
    /**
37
     * Add X-Forwarded-For header to IP address determination
38
     *
39
     * @return void
40
     */
41
    public function useHttpXForwarded()
42
    {
43
        if (array_key_exists('x-forwarded-for', $this->alternativeHeaders) === false) {
44
            $this->alternativeHeaders['x-forwarded-for'] = 'HTTP_X_FORWARDED_FOR';
45
        }
46
    }
47
}
48