Skip to content

Instantly share code, notes, and snippets.

@hyperized
Last active March 3, 2020 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyperized/e57152d1ee7b9ca68704e09787d22679 to your computer and use it in GitHub Desktop.
Save hyperized/e57152d1ee7b9ca68704e09787d22679 to your computer and use it in GitHub Desktop.
<?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