/** * Loads a package file from a file path. * * If the file does not exist, an empty configuration is returned. * * Loaded package files must have a package name set. If none is set, an * exception is thrown. * * @param string $path The path to the package file. * * @return PackageFile The loaded package file. * * @throws StorageException If the file cannot be read. * @throws InvalidConfigException If the file contains invalid * configuration. * @throws UnsupportedVersionException If the version of the package file * is not supported. */ public function loadPackageFile($path) { if (!$this->storage->exists($path)) { return new PackageFile(null, $path); } $serialized = $this->storage->read($path); return $this->serializer->unserializePackageFile($serialized, $path); }
/** * Loads a package file from a file path. * * If the file does not exist, an empty configuration is returned. * * Loaded package files must have a package name set. If none is set, an * exception is thrown. * * @param string $path The path to the package file. * * @return PackageFile The loaded package file. * * @throws FileNotFoundException If the file does not exist. * @throws ReadException If the file cannot be read. * @throws InvalidConfigException If the file contains invalid * configuration. * @throws UnsupportedVersionException If the version of the package file * is not supported. */ public function loadPackageFile($path) { $serialized = $this->storage->read($path); return $this->serializer->unserializePackageFile($serialized, $path); }