`!is_dir($filePath)` -> `is_file($filePath)` - it will be easier to understand.