Settings   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 63
ccs 15
cts 15
cp 1
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessageReadCount() 0 3 1
A shouldReadFromStart() 0 3 1
A getConsumerGroup() 0 3 1
A getConsumerName() 0 3 1
A getMessageWaitTimeout() 0 3 1
A __construct() 0 3 1
A getStreamName() 0 3 1
1
<?php
2
/**
3
 * Copyright Aleksandar Panic
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 **/
17
18
namespace ArekX\DataStreamer\Data;
19
20
use ArekX\DataStreamer\Contracts\StreamSettings;
21
22
/**
23
 * Class Settings
24
 * @package ArekX\DataStreamer\Data
25
 *
26
 * Represents settings to configure the
27
 * stream reader or a writer.
28
 */
29
class Settings implements StreamSettings
30
{
31
    /**
32
     * Settings to be read.
33
     * @var array
34
     */
35
    protected array $settings;
36
37
    /**
38
     * Settings constructor.
39
     * @param array $settings Settings which will be read.
40
     */
41 8
    public function __construct(array $settings)
42
    {
43 8
        $this->settings = $settings;
44 8
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49 8
    public function getStreamName(): string
50
    {
51 8
        return $this->settings['stream'] ?? '';
52
    }
53
54
    /**
55
     * @inheritDoc
56
     */
57 6
    public function getConsumerGroup(): string
58
    {
59 6
        return $this->settings['consumerGroup'] ?? '';
60
    }
61
62
    /**
63
     * @inheritDoc
64
     */
65 6
    public function getConsumerName(): string
66
    {
67 6
        return $this->settings['consumerName'] ?? '';
68
    }
69
70
    /**
71
     * @inheritDoc
72
     */
73 1
    public function shouldReadFromStart(): bool
74
    {
75 1
        return $this->settings['readFromStart'] ?? true;
76
    }
77
78
    /**
79
     * @inheritDoc
80
     */
81 6
    public function getMessageReadCount(): int
82
    {
83 6
        return $this->settings['messagesPerRead'] ?? 1;
84
    }
85
86
    /**
87
     * @inheritDoc
88
     */
89 6
    public function getMessageWaitTimeout(): int
90
    {
91 6
        return $this->settings['waitTimeout'] ?? 10000;
92
    }
93
}