Last active
March 3, 2020 14:48
-
-
Save hyperized/e57152d1ee7b9ca68704e09787d22679 to your computer and use it in GitHub Desktop.
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 declare(strict_types=1); | |
namespace Hyperized\File\Safe; | |
use Hyperized\File\Exceptions\CouldNotGetGroupId; | |
/** | |
* @param string $filename | |
* @return int | |
* @throws CouldNotGetGroupId | |
*/ | |
function filegroup(string $filename): int | |
{ | |
set_error_handler(static function ($severity, $message, $file, $line) { | |
throw new CouldNotGetGroupId($message); | |
}, E_WARNING); | |
$gid = \filegroup($filename); | |
restore_error_handler(); | |
if ($gid === FALSE) { | |
throw new CouldNotGetGroupId( | |
'Could not retrieve gid with filegroup()' | |
); | |
} | |
return $gid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment