Beispiel #1
0
 /**
  * counts frequency of all values from input stream in a private variable
  *
  * @param StreamInterface $input
  * @throws Exception
  */
 public function updateFrequencyArray(StreamInterface $input)
 {
     while (!$input->streamEnded()) {
         $char = $input->getChar();
         if ($char === false) {
             break;
         }
         if (PHP_INT_MAX == $this->frequencyTotal) {
             throw new Exception('the counts in the frequency array are about to exceed ' . PHP_INT_MAX);
         }
         $this->frequencyTotal++;
         if (isset($this->frequency[$char])) {
             $this->frequency[$char]++;
         } else {
             $this->frequency[$char] = 1;
         }
     }
 }