Passed
Pull Request — master (#134)
by Tobias
02:26
created

AutoInteractor::noticeException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of Ekino New Relic bundle.
5
 *
6
 * (c) Ekino - Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ekino\Bundle\NewRelicBundle\NewRelic;
13
14
/**
15
 * This interactor does never assume that the NewRelic extension is installed. It will check
16
 * for the existence of each method EVERY time. This is a good interactor to use when you want
17
 * to enable and disable the NewRelic extension without rebuilding your container.
18
 *
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21
class AutoInteractor implements NewRelicInteractorInterface
22
{
23
    /**
24
     * @var NewRelicInteractorInterface
25
     */
26
    private $interactor;
27
28
    /**
29
     * @param NewRelicInteractorInterface $interactor
30
     */
31
    public function __construct(NewRelicInteractorInterface $real, NewRelicInteractorInterface $fake)
32
    {
33
        $this->interactor = extension_loaded('newrelic') ? $real : $fake;
34
    }
35
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function setApplicationName($name, $key = null, $xmit = false)
41
    {
42
        $this->interactor->setApplicationName($name, $key, $xmit);
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by Ekino\Bundle\NewRelicBun...e::setApplicationName() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function setTransactionName($name)
49
    {
50
        $this->interactor->setTransactionName($name);
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by Ekino\Bundle\NewRelicBun...e::setTransactionName() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function ignoreTransaction ()
57
    {
58
        $this->interactor->ignoreTransaction();
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function addCustomMetric($name, $value)
65
    {
66
        $this->interactor->addCustomMetric($name, $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by Ekino\Bundle\NewRelicBun...face::addCustomMetric() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function addCustomParameter($name, $value)
73
    {
74
        $this->interactor->addCustomParameter($name, $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by Ekino\Bundle\NewRelicBun...e::addCustomParameter() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function getBrowserTimingHeader()
81
    {
82
        return $this->interactor->getBrowserTimingHeader();
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function getBrowserTimingFooter()
89
    {
90
        return $this->interactor->getBrowserTimingFooter();
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function disableAutoRUM()
97
    {
98
        $this->interactor->disableAutoRUM();
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by Ekino\Bundle\NewRelicBun...rface::disableAutoRUM() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
99
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104
    public function noticeError($msg)
105
    {
106
        $this->interactor->noticeError($msg);
0 ignored issues
show
Bug introduced by
The call to Ekino\Bundle\NewRelicBun...nterface::noticeError() has too few arguments starting with errstr. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

106
        $this->interactor->/** @scrutinizer ignore-call */ 
107
                           noticeError($msg);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
107
    }
108
109
    /**
110
     * {@inheritdoc}
111
     */
112
    public function noticeException(\Exception $e)
113
    {
114
        $this->interactor->noticeError($e);
0 ignored issues
show
Bug introduced by
The call to Ekino\Bundle\NewRelicBun...nterface::noticeError() has too few arguments starting with errstr. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

114
        $this->interactor->/** @scrutinizer ignore-call */ 
115
                           noticeError($e);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
$e of type Exception is incompatible with the type integer expected by parameter $errno of Ekino\Bundle\NewRelicBun...nterface::noticeError(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

114
        $this->interactor->noticeError(/** @scrutinizer ignore-type */ $e);
Loading history...
115
    }
116
117
    /**
118
     * {@inheritdoc}
119
     */
120
    public function enableBackgroundJob()
121
    {
122
        $this->interactor->enableBackgroundJob();
123
    }
124
125
    /**
126
     * {@inheritdoc}
127
     */
128
    public function disableBackgroundJob()
129
    {
130
        $this->interactor->disableBackgroundJob();
131
    }
132
133
    /**
134
     * {@inheritdoc}
135
     */
136
    public function endTransaction()
137
    {
138
        $this->interactor->endTransaction();
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by Ekino\Bundle\NewRelicBun...rface::endTransaction() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
139
    }
140
141
    /**
142
     * {@inheritdoc}
143
     */
144
    public function startTransaction($name)
145
    {
146
        $this->interactor->startTransaction($name);
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by Ekino\Bundle\NewRelicBun...ace::startTransaction() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
147
    }
148
}
149