private function getValidRotationAmount($rotationAmount)
    {
        $rotationAmount = (int) $rotationAmount;

        $alphabetSize = $this->getAlphabetSize();

        if ($rotationAmount < 0) {
            $rotationAmount += (int) ceil(-1 * $rotationAmount / $alphabetSize) * $alphabetSize;
        }

        return $rotationAmount;
    }