Passed
Push — master ( 5d5d3a...64c758 )
by Valeriy
01:46
created

Environment::getUserIP()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Ftrrtf\RollbarBundle\Rollbar;
4
5
use Ftrrtf\Rollbar\Environment as BaseEnvironment;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpKernel\Kernel;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
/**
11
 * Configure Symfony specific env.
12
 */
13
class Environment extends BaseEnvironment
14
{
15
    /**
16
     * @var Request
17
     */
18
    protected $request;
19
20
    /**
21
     * Cached values for request.
22
     *
23
     * @return array|null
24
     */
25
    public function getRequestData()
26
    {
27
        parent::getRequestData();
28
29
        if ($this->getRequest() instanceof Request) {
30
            if (in_array($this->getRequest()->getMethod(), array('PUT', 'DELETE'))) {
31
                $this->requestData[$this->getRequest()->getMethod()] = $this->getRequest()->request->all();
32
            }
33
        }
34
35
        return $this->requestData;
36
    }
37
38
    /**
39
     * @return Request
40
     */
41
    public function getRequest()
42
    {
43
        return $this->request;
44
    }
45
46
    /**
47
     * @param Request|null $request
48
     */
49
    public function setRequest($request)
50
    {
51
        $this->request = $request;
52
    }
53
54
    /**
55
     * @param OptionsResolver $resolver
56
     */
57
    protected function setDefaultOptions(OptionsResolver $resolver)
58
    {
59
        parent::setDefaultOptions($resolver);
60
61
        $resolver->setDefaults(
62
            array(
63
                'framework' => Kernel::VERSION,
64
                'anonymize' => false,
65
            )
66
        );
67
    }
68
69
    public function getUserIP()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
70
    {
71
        if ($this->options['anonymize']) {
72
            return null;
73
        }
74
75
        return parent::getUserIP();
76
    }
77
78
    public function getPersonData()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
79
    {
80
        if ($this->options['anonymize']) {
81
            return null;
82
        }
83
84
        return parent::getPersonData();
85
    }
86
}
87