PHP code example of antfroger / progressive-bundle
1. Go to this page and download the library: Download antfroger/progressive-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/ */
public function info(Progressive $progressive): Response
{
if ($progressive->isEnabled('call-center')) {
// Do what you want when the feature `call-center` is enabled
}
}
// src/Progressive/BetweenHours.php
namespace App\Progressive;
use Progressive\ParameterBagInterface;
use Progressive\Rule\RuleInterface;
class BetweenHours implements RuleInterface
{
/**
* {@inheritdoc}
*/
public function getName(): string
{
return 'between-hours';
}
/**
* {@inheritdoc}
*/
public function decide(ParameterBagInterface $bag, array $hours = []): bool
{
if (!isset($hours['start']) || !is_int($hours['start']) || !isset($hours['end']) || !is_int($hours['end'])) {
return false;
}
$now = new \DateTime();
$hour = $now->format('H');
return $hours['start'] <= $hour && $hour < $hours['end'];
}
}
public function customerService(Progressive $progressive): Response
{
if ($progressive->isEnabled('customer-service-chat')) {
// ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.