Completed
Push — master ( 3f58aa...01cbeb )
by Mathijs
04:40
created

JobExchangePublish::getVirtualHost()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace mcorten87\rabbitmq_api\jobs;
4
5
use mcorten87\rabbitmq_api\objects\DeliveryMode;
6
use mcorten87\rabbitmq_api\objects\Exchange;
7
use mcorten87\rabbitmq_api\objects\ExchangeName;
8
use mcorten87\rabbitmq_api\objects\Message;
9
use mcorten87\rabbitmq_api\objects\RoutingKey;
10
use mcorten87\rabbitmq_api\objects\RoutingKeyUnknown;
11
use mcorten87\rabbitmq_api\objects\VirtualHost;
12
13
class JobExchangePublish extends JobBase
14
{
15
    /**
16
     * @var VirtualHost
17
     */
18
    private $virtualHost;
19
20
    /**
21
     * @var ExchangeName
22
     */
23
    private $exchangeName;
24
25
    /** @var  DeliveryMode */
26
    private $deliveryMode;
27
28
    /** @var Message */
29
    private $message;
30
31
    /** @var  RoutingKey */
32
    private $routingKey;
33
34
       /** @return VirtualHost */
35
    public function getVirtualHost() : VirtualHost
36
    {
37
        return $this->virtualHost;
38
    }
39
40
    /**
41
     * @return ExchangeName
42
     */
43
    public function getExchangeName() : ExchangeName
44
    {
45
        return $this->exchangeName;
46
    }
47
48
    /**
49
     * @return Message
50
     */
51
    public function getMessage(): Message
52
    {
53
        return $this->message;
54
    }
55
56
    /**
57
     * @return DeliveryMode
58
     */
59
    public function getDeliveryMode(): DeliveryMode
60
    {
61
        return $this->deliveryMode;
62
    }
63
64
    /**
65
     * @return RoutingKey
66
     */
67
    public function getRoutingKey(): RoutingKey
68
    {
69
        return $this->routingKey;
70
    }
71
72
    /**
73
     * JobExchangeCreate constructor.
74
     * @param VirtualHost $virtualHost
75
     * @param ExchangeName $exchangeName
76
     */
77
    public function __construct(
78
        VirtualHost $virtualHost,
79
        ExchangeName $exchangeName,
80
        Message $message,
81
        DeliveryMode $deliveryMode,
82
        RoutingKey $routingKey = null
83
    ) {
84
        if ($routingKey === null) {
85
            $routingKey = new RoutingKeyUnknown();
86
        }
87
88
        $this->virtualHost = $virtualHost;
89
        $this->exchangeName = $exchangeName;
90
        $this->message = $message;
91
92
        $this->deliveryMode = $deliveryMode;
93
        $this->routingKey = $routingKey;
0 ignored issues
show
Documentation Bug introduced by
It seems like $routingKey can also be of type object<mcorten87\rabbitm...ects\RoutingKeyUnknown>. However, the property $routingKey is declared as type object<mcorten87\rabbitmq_api\objects\RoutingKey>. 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...
94
    }
95
}
96