Airship\Engine\Continuum\Updaters\UpdateFile::hashMatches PHP Method

hashMatches() public method

Does the given hash match the file?
public hashMatches ( string $hash ) : boolean
$hash string
return boolean
    public function hashMatches(string $hash) : bool
    {
        return \hash_equals($this->hash, $hash);
    }

Usage Example

Example #1
0
 /**
  * Install the new version
  *
  * If we get to this point:
  *
  * 1. We know the signature is signed by the supplier.
  * 2. The hash was checked into Keyggdrasil, which
  *    was independently vouched for by our peers.
  *
  * @param UpdateInfo $info (part of definition but not used here)
  * @param UpdateFile $file
  * @throws CouldNotUpdate
  * @throws MotifZipFailed
  */
 protected function install(UpdateInfo $info, UpdateFile $file)
 {
     if (!$file->hashMatches($info->getChecksum())) {
         throw new CouldNotUpdate(\__('Checksum mismatched'));
     }
     // Let's open the update package:
     $path = $file->getPath();
     $zip = new \ZipArchive();
     $res = $zip->open($path);
     if ($res !== true) {
         throw new MotifZipFailed(\__("ZIP Error: %s", "default", $res));
     }
     $dir = \implode(DIRECTORY_SEPARATOR, [ROOT, 'Motifs', $this->supplier->getName(), $this->name]);
     // Extract the new files to the current directory
     if (!$zip->extractTo($dir)) {
         throw new CouldNotUpdate();
     }
     // Make sure we update the version info. in the DB cache:
     $this->updateDBRecord('Motif', $info);
     self::$continuumLogger->store(LogLevel::INFO, 'Motif update installed', $this->getLogContext($info, $file));
 }
All Usage Examples Of Airship\Engine\Continuum\Updaters\UpdateFile::hashMatches