Code Duplication    Length = 10-11 lines in 3 locations

examples/SafeBrowsing/save-prefixes-db.php 1 location

@@ 74-84 (lines=11) @@
71
        $safeBrowsing->setMalwareShavars($shaVarsList);
72
        $malwaresData = $safeBrowsing->getMalwaresData();
73
74
        if (is_array($malwaresData)) {
75
            foreach ($malwaresData as $shaVar => $chunks) {
76
                if (isset($chunks['added'])) {
77
                    foreach ($chunks['added'] as $chunkNum => $hashPrefixes) {
78
                        foreach ($hashPrefixes as $hashPrefix) {
79
                            $redisAdapter->saveHashPrefix($shaVar, $chunkNum, $hashPrefix);
80
                        }
81
                    }
82
                }
83
            }
84
        }
85
        ?>
86
        <div class="alert alert-success">Сохранены префиксы хешей в Redis</div>
87
        <div>

examples/SafeBrowsing/update-prefixes-db.php 2 locations

@@ 123-132 (lines=10) @@
120
                foreach ($malwaresData as $shaVar => $chunks) {
121
122
                    //Need add new malwares hash prefixes
123
                    if (isset($chunks['added'])) {
124
                        foreach ($chunks['added'] as $chunkNum => $hashPrefixes) {
125
                            foreach ($hashPrefixes as $hashPrefix) {
126
                                if (!$redisAdapter->getHashPrefix($hashPrefix)) {
127
                                    $redisAdapter->saveHashPrefix($shaVar, $chunkNum, $hashPrefix);
128
                                    $newChunks++;
129
                                }
130
                            }
131
                        }
132
                    }
133
134
                    //Need remove chunks
135
                    if (isset($chunks['removed'])) {
@@ 135-144 (lines=10) @@
132
                    }
133
134
                    //Need remove chunks
135
                    if (isset($chunks['removed'])) {
136
                        foreach ($chunks['removed'] as $chunkNum => $hashPrefixes) {
137
                            foreach ($hashPrefixes as $hashPrefix) {
138
                                if ($redisAdapter->getHashPrefix($hashPrefix)) {
139
                                    $redisAdapter->removeHashPrefix($shaVar, $chunkNum, $hashPrefix);
140
                                    $removedChunks++;
141
                                }
142
                            }
143
                        }
144
                    }
145
146
                    //Need remove chunks range
147
                    if (isset($chunks['delete_added_ranges'])) {