Added an additional type check

It seems like $rule->generate($path) can also be of type false; however, ltrim() does only seem to accept string.
Merge pull request #1187 from siad007/patch-10

Added an additional type check