1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-04 02:14:06 +02:00
This commit is contained in:
Robin Appelman 2019-04-12 14:00:20 +02:00
commit 73469d2aa1
29 changed files with 140 additions and 149 deletions

View file

@ -4,11 +4,13 @@ declare(strict_types=1);
namespace Demostf\API\Demo;
use InvalidArgumentException;
class HeaderParser {
/**
* @param string $head string containing the demo header binary data
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*
* @return Header
*/
@ -18,7 +20,7 @@ class HeaderParser {
$head
);
if (!isset($info['type']) || 'HL2DEMO' !== $info['type']) {
throw new \InvalidArgumentException('Not an HL2 demo');
throw new InvalidArgumentException('Not an HL2 demo');
}
return Header::fromArray($info);
@ -29,7 +31,7 @@ class HeaderParser {
*
* @param resource $stream
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*
* @return Header
*/
@ -44,13 +46,13 @@ class HeaderParser {
*
* @param string $path
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*
* @return Header
*/
public function parseHeader(string $path): Header {
if (!is_readable($path)) {
throw new \InvalidArgumentException('Unable to open demo: ' . $path);
throw new InvalidArgumentException('Unable to open demo: ' . $path);
}
$fh = fopen($path, 'r');