| Conditions | 6 | 
| Paths | 13 | 
| Total Lines | 33 | 
| Code Lines | 19 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 95 | protected function generateTable(int $polynomial): array  | 
            ||
| 96 |     { | 
            ||
| 97 | $tableSize = 256;  | 
            ||
| 98 | |||
| 99 | $mask = (((1 << ($this->bitLength - 1)) - 1) << 1) | 1;  | 
            ||
| 100 | $highBit = 1 << ($this->bitLength - 1);  | 
            ||
| 101 | |||
| 102 | $crctab = [];  | 
            ||
| 103 | |||
| 104 |         for ($i = 0; $i < $tableSize; ++$i) { | 
            ||
| 105 | $crc = $i;  | 
            ||
| 106 |             if ($this->reverseIn) { | 
            ||
| 107 | $crc = $this->binaryReverse($crc, 8);  | 
            ||
| 108 | }  | 
            ||
| 109 | |||
| 110 | $crc <<= $this->bitLength - 8;  | 
            ||
| 111 | |||
| 112 |             for ($j = 0; $j < 8; ++$j) { | 
            ||
| 113 | $bit = $crc & $highBit;  | 
            ||
| 114 | $crc <<= 1;  | 
            ||
| 115 |                 if ($bit) { | 
            ||
| 116 | $crc ^= $polynomial;  | 
            ||
| 117 | }  | 
            ||
| 118 | }  | 
            ||
| 119 | |||
| 120 |             if ($this->reverseOut) { | 
            ||
| 121 | $crc = $this->binaryReverse($crc, $this->bitLength);  | 
            ||
| 122 | }  | 
            ||
| 123 | $crc &= $mask;  | 
            ||
| 124 | $crctab[] = $crc;  | 
            ||
| 125 | }  | 
            ||
| 126 | |||
| 127 | return $crctab;  | 
            ||
| 128 | }  | 
            ||
| 152 |