1. Go to this page and download the library: Download kefyusuf/laravel-bloom-gate 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/ */
kefyusuf / laravel-bloom-gate example snippets
namespace App\Bloom;
use Kefyusuf\BloomGate\Contracts\{AuthoritativeSet, FilterDefinition, ValueNormalizer};
use Kefyusuf\BloomGate\Core\{AuthoritativeSetIdentity, ConsistencyContract, NormalizationIdentity, NormalizedValue};
final class CountryCodeFilter implements FilterDefinition
{
public function normalizer(): ValueNormalizer
{
return new class implements ValueNormalizer {
public function identity(): NormalizationIdentity
{
return NormalizationIdentity::fromString('country-code-uppercase@1');
}
public function normalize(string|int $value): NormalizedValue
{
return NormalizedValue::fromBytes(strtoupper(trim((string) $value)));
}
};
}
public function authoritativeSet(): AuthoritativeSet
{
return new class implements AuthoritativeSet {
public function identity(): AuthoritativeSetIdentity
{
return AuthoritativeSetIdentity::fromString('demo-country-codes@1');
}
public function values(): iterable
{
yield from ['TR', 'DE', 'US'];
}
public function exists(NormalizedValue $value): bool
{
return in_array($value->bytes(), ['TR', 'DE', 'US'], true);
}
};
}
public function consistency(): ConsistencyContract
{
return ConsistencyContract::ImmutableV1;
}
}
interface FilterDefinition
{
public function normalizer(): ValueNormalizer;
public function authoritativeSet(): AuthoritativeSet;
public function consistency(): ConsistencyContract;
}