BaseApiAwareAction::setApi()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2.032
1
<?php
2
3
namespace PayumTW\Ips\Action\Api;
4
5
use PayumTW\Ips\Api;
6
use Payum\Core\ApiAwareInterface;
7
use Payum\Core\Action\ActionInterface;
8
use Payum\Core\Exception\UnsupportedApiException;
9
10
abstract class BaseApiAwareAction implements ActionInterface, ApiAwareInterface
11
{
12
    /**
13
     * @var \Payum\Ips\Api
14
     */
15
    protected $api;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 6
    public function setApi($api)
21
    {
22 6
        if (false == $api instanceof Api) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
23
            throw new UnsupportedApiException('Not supported.');
24
        }
25
26 6
        $this->api = $api;
0 ignored issues
show
Documentation Bug introduced by
It seems like $api of type object<PayumTW\Ips\Api> is incompatible with the declared type object<Payum\Ips\Api> of property $api.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
27 6
    }
28
}
29