Created
April 14, 2019 16:00
-
-
Save szyku/84f91d5e973688e1d91d683fe1bd7bc5 to your computer and use it in GitHub Desktop.
naivefopen3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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