Skip to content

Commit 30bdeba

Browse files
committed
Merge branch 'main' of https://github.com/indy2kro/php-iso
2 parents 8586c95 + af04598 commit 30bdeba

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "composer" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

composer.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/IsoFile.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
class IsoFile
1111
{
1212
/**
13-
* @var resource
13+
* @var array<int, Descriptor>
1414
*/
15-
protected mixed $fileHandle;
16-
15+
public array $descriptors = [];
1716
/**
18-
* @var array<int, Descriptor>
17+
* @var resource
1918
*/
20-
protected array $descriptors = [];
19+
protected mixed $fileHandle;
2120

2221
public function __construct(protected string $isoFilePath)
2322
{

src/Util/IsoDate.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public static function init17(array &$buffer, int &$offset): ?Carbon
5151
$hour = (int) substr($date, 8, 2);
5252
$min = (int) substr($date, 10, 2);
5353
$sec = (int) substr($date, 12, 2);
54-
// $ms = (int) substr($date, 14, 2);
55-
$utcOffset = $buffer[16];
54+
$ms = (int) substr($date, 14, 2);
55+
$utcOffset = (int) substr($date, 16, 2);
5656
$utcOffsetHours = (int) round($utcOffset / 4);
5757

5858
$offset += 1;
@@ -61,6 +61,12 @@ public static function init17(array &$buffer, int &$offset): ?Carbon
6161
return null;
6262
}
6363

64-
return Carbon::create($year, $month, $day, $hour, $min, $sec, $utcOffsetHours);
64+
$date = Carbon::create($year, $month, $day, $hour, $min, $sec, $utcOffsetHours);
65+
66+
if ($date !== null) {
67+
$date->addMilliseconds($ms);
68+
}
69+
70+
return $date;
6571
}
6672
}

tests/IsoFileTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ public function testConstructorInvalidFile(): void
2929
}
3030

3131
#[DataProvider('isoFilesDataProvider')]
32-
public function testConstructorExistingFile(string $testFile): void
32+
public function testConstructorExistingFile(string $testFile, int $descriptorCount): void
3333
{
3434
$isoFile = new IsoFile($testFile);
3535
$this->assertInstanceOf(IsoFile::class, $isoFile);
36+
$this->assertCount($descriptorCount, $isoFile->descriptors);
37+
print_r($isoFile);
3638
}
3739

3840
public static function isoFilesDataProvider(): Iterator
3941
{
40-
yield [dirname(__FILE__, 2) . '/fixtures/1mb.iso'];
41-
yield [dirname(__FILE__, 2) . '/fixtures/test.iso'];
42+
yield [dirname(__FILE__, 2) . '/fixtures/1mb.iso', 3];
43+
yield [dirname(__FILE__, 2) . '/fixtures/test.iso', 2];
4244
}
4345
}

0 commit comments

Comments
 (0)