public function stem($word) { if (!is_string($word)) { throw new \Exception('Parameter one must be a string!', 111); } if (strlen(\stripslashes($word)) < 3) { return $word; } $this->sb = new StringBuilder(\strtolower(\stripslashes($word))); if (0 === strcmp("'", $this->sb->offsetGet(0))) { $this->sb->Remove(0); } // FIXME: Exceceptions test should go before creating StringBuilder object $this->exceptions->rewind(); while ($this->exceptions->valid()) { if (0 === strcmp($word, $this->exceptions->key())) { return $this->exceptions->current(); } $this->exceptions->next(); } $this->changeY(); $this->computeR1R2(); $this->step0(); $this->step1a(); $this->exceptions2->rewind(); while ($this->exceptions2->valid()) { if (0 === strcmp($this->sb, $this->exceptions2->current())) { return $this->exceptions2->current(); } $this->exceptions2->next(); } $this->step1b(); $this->step1c(); $this->step2(); $this->step3(); $this->step4(); $this->step5(); return strtolower($this->sb); }