PHP code example of evotodi / password-meter-bundle

1. Go to this page and download the library: Download evotodi/password-meter-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

evotodi / password-meter-bundle example snippets


// src/Service/PasswordMeterRequirementsProvider.php

namespace App\Service;

use Evotodi\PasswordMeterBundle\Interfaces\RequirementsInterface;
use Evotodi\PasswordMeterBundle\Models\Requirements;

class PasswordMeterRequirementsProvider implements RequirementsInterface
{

	public function getRequirements(): Requirements
	{
		return new Requirements(minLength: 10);
	}
}

// src/Service/PasswordMeterScoreProvider.php

namespace App\Service;

use Evotodi\PasswordMeterBundle\Interfaces\ScoreRangeInterface;

class PasswordMeterScoreProvider implements ScoreRangeInterface
{

	public function getScoreRange(): array
	{
		return [
            '40' => 'veryWeak', // 001 <= x <  040
            '80' => 'weak', // 040 <= x <  080
            '120' => 'medium', // 080 <= x <  120
            '180' => 'strong', // 120 <= x <  180
            '200' => 'veryStrong', // 180 <= x <  200
            '_' => 'perfect', //  >= 200
        ];
	}
}