Code Duplication    Length = 17-18 lines in 3 locations

src/AbstractEnumSet.php 1 location

@@ 170-187 (lines=18) @@
167
     * Count the number of elements
168
     * @return int
169
     */
170
    public function count()
171
    {
172
        $count   = 0;
173
        $byteLen = strlen($this->bitset);
174
        for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
175
            if ($this->bitset[$bytePos] === "\0") {
176
                continue; // fast skip null byte
177
            }
178
179
            for ($bitPos = 0; $bitPos < 8; ++$bitPos) {
180
                if ((ord($this->bitset[$bytePos]) & (1 << $bitPos)) !== 0) {
181
                    ++$count;
182
                }
183
            }
184
        }
185
186
        return $count;
187
    }
188
189
    /**
190
     * Check if this EnumSet is the same as other

src/BinaryEnumSet.php 1 location

@@ 152-169 (lines=18) @@
149
     * Count the number of elements
150
     * @return int
151
     */
152
    public function count()
153
    {
154
        $count   = 0;
155
        $byteLen = strlen($this->bitset);
156
        for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
157
            if ($this->bitset[$bytePos] === "\0") {
158
                continue; // fast skip null byte
159
            }
160
161
            for ($bitPos = 0; $bitPos < 8; ++$bitPos) {
162
                if ((ord($this->bitset[$bytePos]) & (1 << $bitPos)) !== 0) {
163
                    ++$count;
164
                }
165
            }
166
        }
167
168
        return $count;
169
    }
170
171
    /**
172
     * Check if this EnumSet is the same as other

src/EnumSet.php 1 location

@@ 263-279 (lines=17) @@
260
     * @see count
261
     * @see doCountInt
262
     */
263
    private function doCountBin()
264
    {
265
        $count = 0;
266
        $byteLen = strlen($this->bitset);
267
        for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
268
            if ($this->bitset[$bytePos] === "\0") {
269
                continue; // fast skip null byte
270
            }
271
272
            for ($bitPos = 0; $bitPos < 8; ++$bitPos) {
273
                if ((ord($this->bitset[$bytePos]) & (1 << $bitPos)) !== 0) {
274
                    ++$count;
275
                }
276
            }
277
        }
278
        return $count;
279
    }
280
281
    /**
282
     * Count the number of elements.