PHP Classes

File: src/PasswordHelper/StrengthChecker.php

Recommend this page to a friend!
  Classes of John Conde   PHP Password Validation Helper   src/PasswordHelper/StrengthChecker.php  
File: src/PasswordHelper/StrengthChecker.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Password Validation Helper
Generate and check a password according to rules
Author: By
Last change: refactor: minor code cleanup
refactor: minor code cleanup
refactor: update codebase for PHP 8.0 compatibility

- Updated test cases in PolicyTest, ValidatorTest, and GeneratorTest to match the new class interfaces and expectations.
- Added getter methods for minLength and maxLength in the Generator class.
- Updated assertions in GeneratorTest to use PHPUnit 8.5 compatible methods.
- Adjusted test expectations in ValidatorTest to align with the current validation logic.

This refactoring ensures that the codebase is fully compatible with PHP 8.0 while maintaining the intended functionality and test coverage.
feat: Refactor password strength scoring to use a 1-100 scale

This commit introduces a comprehensive scoring system for password strength, replacing the previous categorical approach. The new system evaluates passwords based on four key factors:

- Length (up to 30 points): Rewards passwords between 8 and 20 characters.
- Character Variety (up to 30 points): Awards points for using uppercase, lowercase, numbers, and special characters, with bonuses for mixed case and multiple character types.
- Complexity (up to 20 points): Checks for repeated characters, sequential patterns, common passwords, and dictionary words.
- Entropy (up to 20 points): Calculates password entropy based on character set size and length.

Key improvements:
- Early returns for empty and very short passwords (score of 1)
- Robust checks for common patterns and keyboard sequences
- Comprehensive test suite using data providers
- Type-safe implementation with strict return types

The scoring system now provides a more granular and accurate assessment of password strength, making it easier to enforce security policies and guide users toward stronger passwords.

Tests: 60 tests, 114 assertions
Improve docblocks, restore Validator compatibility, and fix Generator return types

- Enhanced docblock comments for all classes in src/PasswordHelper to be more descriptive and PSR-12 compliant.
- Fixed Generator::getRandomCharacter() to always return a string, preventing type errors.
- Reintroduced protected meetsMinimum* methods in Validator to support legacy and test code.
Added PHP Documentor support
Date: 7 days ago
Size: 10,550 bytes

You need to be a registered user and login to get this file.

Login Immediately with your account on: