Skip to content

Commit b62ee6d

Browse files
committed
Move the parser instantiation below the error checks as it is not used before it. Would be extra resources if the thing is thrown. Also more the $this->path setting into else since we don't want the whole string to be set as a path if we are passing in a large chunk of data.
1 parent 679bb9e commit b62ee6d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Pyrus/PackageFile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ function __construct($package, $class = 'Pyrus\PackageFile\v2', $isString = fals
3434
return $this->info = $package;
3535
}
3636

37-
$this->path = $package;
38-
$parser = new PackageFile\Parser\v2;
3937
if ($isString) {
4038
$data = $package;
4139
} else {
40+
$this->path = $package;
4241
$data = file_get_contents($package);
4342
}
4443

@@ -47,6 +46,7 @@ function __construct($package, $class = 'Pyrus\PackageFile\v2', $isString = fals
4746
. $package . ' or file was empty.');
4847
}
4948

49+
$parser = new PackageFile\Parser\v2;
5050
$this->info = $parser->parse($data, $package, $class);
5151
}
5252

0 commit comments

Comments
 (0)