diff --git a/src/ncc/Enums/Versions.php b/src/ncc/Enums/Versions.php index b7d1314..a2ac68b 100644 --- a/src/ncc/Enums/Versions.php +++ b/src/ncc/Enums/Versions.php @@ -29,11 +29,6 @@ */ case CREDENTIALS_STORE_VERSION = '1.0.0'; - /** - * The current version of the package lock structure file format - */ - case PACKAGE_LOCK_VERSION = '2.0.0'; - /** * Generic version of the package structure file format (latest) */ diff --git a/src/ncc/Objects/PackageLock.php b/src/ncc/Objects/PackageLock.php index a4d42b1..24bbb4a 100644 --- a/src/ncc/Objects/PackageLock.php +++ b/src/ncc/Objects/PackageLock.php @@ -35,10 +35,12 @@ class PackageLock implements BytecodeObjectInterface { + private const string PACKAGE_LOCK_VERSION = '2.0.0'; + /** * The version of package lock file structure * - * @var string + * @var Versions */ private $package_lock_version; @@ -59,11 +61,11 @@ /** * Public Constructor */ - public function __construct(array $entries=[], string $package_lock_version=Versions::PACKAGE_LOCK_VERSION->value, ?int $last_updated_timestamp=null) + public function __construct(array $entries=[], ?int $last_updated_timestamp=null) { $this->entries = $entries; - $this->package_lock_version = $package_lock_version; - $this->last_updated_timestamp = $last_updated_timestamp ?? time(); + $this->package_lock_version = self::PACKAGE_LOCK_VERSION; + $this->last_updated_timestamp = $last_updated_timestamp ? null : time(); } /** @@ -93,7 +95,7 @@ */ private function update(): void { - $this->package_lock_version = Versions::PACKAGE_LOCK_VERSION; + $this->package_lock_version = self::PACKAGE_LOCK_VERSION; $this->last_updated_timestamp = time(); } @@ -280,7 +282,7 @@ }, $entries_array); - $package_lock_version = Functions::array_bc($data, 'package_lock_version') ?? Versions::PACKAGE_LOCK_VERSION->value; + $package_lock_version = Functions::array_bc($data, 'package_lock_version') ?? self::PACKAGE_LOCK_VERSION; $last_updated_timestamp = Functions::array_bc($data, 'last_updated_timestamp') ?? time(); if($package_lock_version === null) @@ -288,6 +290,6 @@ throw new ConfigurationException('Package lock version is missing'); } - return new self($entries, $package_lock_version, $last_updated_timestamp); + return new self($entries, $last_updated_timestamp); } } \ No newline at end of file