Conditions | 7 |
Paths | 32 |
Total Lines | 38 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
55 | public function setData(array $topics, array $brokersResult): bool |
||
56 | { |
||
57 | $brokers = []; |
||
58 | |||
59 | foreach ($brokersResult as $value) { |
||
60 | $brokers[$value['nodeId']] = $value['host'] . ':' . $value['port']; |
||
61 | } |
||
62 | |||
63 | $changed = false; |
||
64 | |||
65 | if (serialize($this->brokers) !== serialize($brokers)) { |
||
66 | $this->brokers = $brokers; |
||
67 | |||
68 | $changed = true; |
||
69 | } |
||
70 | |||
71 | $newTopics = []; |
||
72 | foreach ($topics as $topic) { |
||
73 | if ((int)$topic['errorCode'] !== Protocol::NO_ERROR) { |
||
74 | continue; |
||
75 | } |
||
76 | |||
77 | $item = []; |
||
78 | |||
79 | foreach ($topic['partitions'] as $part) { |
||
80 | $item[$part['partitionId']] = $part['leader']; |
||
81 | } |
||
82 | |||
83 | $newTopics[$topic['topicName']] = $item; |
||
84 | } |
||
85 | |||
86 | if (serialize($this->topics) !== serialize($newTopics)) { |
||
87 | $this->topics = $newTopics; |
||
88 | |||
89 | $changed = true; |
||
90 | } |
||
91 | |||
92 | return $changed; |
||
93 | } |
||
115 | } |