Issues (51)

TradableAssetPairs/TradableAssetPairsRequest.php (2 issues)

1
<?php
2
3
namespace HanischIt\KrakenApi\Call\TradableAssetPairs;
4
5
use HanischIt\KrakenApi\Enum\VisibilityEnum;
6
use HanischIt\KrakenApi\Model\RequestInterface;
7
8
/**
9
 * Class TradableAssetPairsRequest
10
 * @package HanischIt\KrakenApi\Call\TradableAssetPairs
11
 */
12
class TradableAssetPairsRequest implements RequestInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    private $info;
18
    /**
19
     * @var array
20
     */
21
    private $pair;
22
23
    /**
24
     * TradableAssetPairsRequest constructor.
25
     * @param string $info
26
     * @param string $pair
27
     */
28 2
    public function __construct($info = 'info', $pair = null)
29
    {
30 2
        $this->info = $info;
31 2
        $this->pair = $pair;
0 ignored issues
show
Documentation Bug introduced by
It seems like $pair can also be of type string. However, the property $pair is declared as type array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
32 2
    }
33
34
35
    /**
36
     * Returns the api request name
37
     *
38
     * @return string
39
     */
40 1
    public function getMethod()
41
    {
42 1
        return 'AssetPairs';
43
    }
44
45
    /**
46
     * @return string
47
     */
48 1
    public function getVisibility()
49
    {
50 1
        return VisibilityEnum::VISIBILITY_PUBLIC;
51
    }
52
53
    /**
54
     * @return array
55
     */
56 1
    public function getRequestData()
57
    {
58 1
        $arr = [];
59 1
        $arr["info"] = $this->info;
60 1
        if (null !== $this->pair) {
0 ignored issues
show
The condition null !== $this->pair can never be false.
Loading history...
61 1
            $arr["pair"] = $this->pair;
62 1
        }
63 1
        return $arr;
64
    }
65
66
    /**
67
     * @return string
68
     */
69 1
    public function getResponseClassName()
70
    {
71 1
        return TradableAssetPairsResponse::class;
72
    }
73
}
74