GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Qos::count()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
4
namespace AmqpWorkers\Definition;
5
6
/**
7
 * QoS definition. Defines how many unacknowledged message Consumer can get from RabbitMQ.
8
 * Use it with `Consumer::withQos()`.
9
 *
10
 * @see https://www.rabbitmq.com/consumer-prefetch.html
11
 *
12
 * @package AmqpWorkers\Definition
13
 * @author Alex Panshin <[email protected]>
14
 * @since 1.0
15
 */
16
class Qos
17
{
18
    /**
19
     * CAUTION: Looks like phpamqplib did not implement this feature!
20
     * @var int prefetch size in bytes
21
     */
22
    private $prefetchSize = 0;
23
24
    /**
25
     * @var int prefetch count in items
26
     */
27
    private $prefetchCount = 0;
28
29
    /**
30
     * @var bool if for true this setting is channel-wide
31
     */
32
    private $global = false;
33
34
    /**
35
     * Simple fluent constructor to avoid weird-looking constructions like
36
     *
37
     * ```php
38
     * $qos = (new Qos())->count(10);
39
     * ```
40
     *
41
     * @return Qos
42
     */
43
    public static function factory()
44
    {
45
        return new Qos();
46
    }
47
48
    /**
49
     * Sets `prefetch_size` qos parameter for channel or consumer
50
     *
51
     * CAUTION: Looks like phpamqplib did not implement this feature!
52
     *
53
     * @see https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.prefetch-size
54
     * @default 0 disables limit
55
     * @param int $value prefetch size in bytes
56
     * @return $this
57
     */
58
    public function size($value)
59
    {
60
        $this->prefetchSize = $value;
61
        return $this;
62
    }
63
64
    /**
65
     * Sets `prefetch_count` qos parameter for channel or consumer
66
     *
67
     * @see https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.prefetch-count
68
     * @default 0 disables limit
69
     * @param int $value prefetch size in items
70
     * @return $this
71
     */
72
    public function count($value)
73
    {
74
        $this->prefetchCount = $value;
75
        return $this;
76
    }
77
78
    /**
79
     * Sets `global` qos parameter.
80
     * This parameter defines if those settings should be used for all channel or only for current Consumer.
81
     * By default settings are consumer-wide.
82
     *
83
     * @see https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global
84
     * @default false
85
     * @param boolean $value
86
     * @return $this
87
     */
88
    public function isGlobal($value)
89
    {
90
        $this->global = $value;
91
        return $this;
92
    }
93
94
    /**
95
     * Returns all parameters in same order as they are used in PhpAmqpLib\Channel\AMQPChannel::basic_qos()
96
     *
97
     * @see \PhpAmqpLib\Channel\AMQPChannel::basic_qos()
98
     * @return array
99
     */
100
    public function listParams()
101
    {
102
        return [$this->prefetchSize, $this->prefetchCount, $this->global];
103
    }
104
}
105