You are here

FailedCheckumFilter.php in Automatic Updates 8

Same filename and directory in other branches
  1. 7 vendor/drupal/php-signify/src/FailedCheckumFilter.php

Namespace

Drupal\Signify

File

vendor/drupal/php-signify/src/FailedCheckumFilter.php
View source
<?php

namespace Drupal\Signify;

use Iterator;
class FailedCheckumFilter extends \FilterIterator {
  protected $workingDirectory;
  public function __construct(Iterator $iterator, $working_directory) {
    parent::__construct($iterator);
    $this->workingDirectory = $working_directory;
  }

  /**
   * {@inheritdoc}
   */
  public function accept() {

    /** @var \Drupal\Signify\VerifierFileChecksum $checksum */
    $checksum = $this
      ->current();
    $hash_file_path = $this->workingDirectory . DIRECTORY_SEPARATOR . $checksum->filename;
    $algorithm = strtolower($checksum->algorithm);
    $hash = @hash_file($algorithm, $hash_file_path);
    return $hash !== $checksum->hex_hash;
  }

}

Classes