1) { throw new UnexpectedValueException('Invalid scheme to open file'); } $path = (realpath($filename) ?: ''); if ('' === $path) { throw new RuntimeException('Unable to locate the file to open'); } /** @noinspection PhpUsageOfSilenceOperatorInspection */ $contents = @file_get_contents($path, false) ?: ''; if ('' === $contents) { throw new RuntimeException('File content is empty'); } return $contents; } }