Skip to content

Instantly share code, notes, and snippets.

@tsh-code
Forked from szyku/naive3.php
Created June 10, 2019 09:38
Show Gist options
  • Save tsh-code/55688c626c3ed6a8134feab7919e3e5f to your computer and use it in GitHub Desktop.
Save tsh-code/55688c626c3ed6a8134feab7919e3e5f to your computer and use it in GitHub Desktop.
naivefopen3
<?php
class XYZ {
// ...
public static function openForRead(string $id): ?SplFileObject
{
$fileInfo = new SplFileInfo($id);
try {
return $fileInfo->openFile('r');
} catch (\Exception $e) {
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment