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.