PHP code example of solution10 / heat

1. Go to this page and download the library: Download solution10/heat 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/ */

    

solution10 / heat example snippets


$c = new Doctrine\Common\Cache\RedisCache();
$h = new Solution10\Heat\Heat($_SERVER['REMOTE_ADDR'], $c);

$c = new Doctrine\Common\Cache\RedisCache();
$h = new Solution10\Heat\Heat($_SERVER['REMOTE_ADDR'], $c);

if ($user->gotTheirPasswordWrong()) {
    $h->increase(25);
}

if ($user->solvedCAPCTHA()) {
    $h->decrease(50);
}

// Boolean checks;
$h->isSafe();
$h->isWarning();
$h->isCritical();

// Checking state against constants;
$h->getState() === Heat::SAFE;
$h->getState() === Heat::WARNING;
$h->getState() === Heat::CRITICAL;

$h->getLifetime();
$h->setLifetime(3600);

$h->getIdentifier();
$h->setIdentifier(string $identifier);

$h->getStorage();
$h->setStorage(Cache $storage);

$h->getStoragePrefix();
$h->setStoragePrefix(string $storagePrefix);

$h->getMaxTemperature();
$h->setMaxTemperature(int $maxTemperature);

$h->getMinTemperature();
$h->setMinTemperature(int $minTemperature);

$h->getSafeThreshold();
$h->setSafeThreshold(float $safeThreshold);

$h->getLifetime();
$h->setLifetime(int $lifetime);

$app = new Silex\Application();
$app->register(new \Solution10\Heat\HeatTrackerServiceProvider(), [
    's10.heat.storage' => new RedisCache() // replace as appropriate
]);