- //Iterate on each character
- foreach(str_split($data) as $k => $c) {
- if (isset($this->rev[$c]) && isset($this->alpha[($this->rev[$c]+$this->offset)%$this->count])) {
- //XXX: Remap char to an other one
- $ret .= chr(($this->rev[$c] - $this->offset + $this->count) % $this->count);
+ //With data
+ if (!empty($data)) {
+ //Iterate on each character
+ foreach(str_split($data) as $k => $c) {
+ if (isset($this->rev[$c]) && isset($this->alpha[($this->rev[$c]+$this->offset)%$this->count])) {
+ //XXX: Remap char to an other one
+ $ret .= chr(($this->rev[$c] - $this->offset + $this->count) % $this->count);
+ } else {
+ throw new \RuntimeException(sprintf('Unable to retrieve character: %c', $c));
+ }