CallCounterPasswordHasher.php 637 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace TestApp\Auth;
  3. use Cake\Auth\AbstractPasswordHasher;
  4. use InvalidArgumentException;
  5. class CallCounterPasswordHasher extends AbstractPasswordHasher
  6. {
  7. public $callCount = 0;
  8. /**
  9. * @inheritDoc
  10. */
  11. public function hash($password)
  12. {
  13. $this->callCount++;
  14. return 'hash123';
  15. }
  16. /**
  17. * @inheritDoc
  18. */
  19. public function check($password, $hashedPassword)
  20. {
  21. if ($hashedPassword == null || $hashedPassword === '') {
  22. throw new InvalidArgumentException('Empty hash not expected');
  23. }
  24. $this->callCount++;
  25. return false;
  26. }
  27. }