setono / consent-contracts
Generic abstraction related to consent
Installs: 55 119
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.18
- setono/code-quality-pack: ^2.4
README
This library serves as a building block for handling consent related implementations in your library or application.
Install
composer require setono/consent-contracts
Usage
<?php use Setono\Consent\Consents; use Setono\Consent\ConsentCheckerInterface; final class YourService { private ConsentCheckerInterface $consentChecker; public function __construct(ConsentCheckerInterface $consentChecker) { $this->consentChecker = $consentChecker; } public function __invoke() { if ($this->consentChecker->isGranted(Consents::CONSENT_MARKETING)) { // marketing consent is granted, and you can set your marketing related cookie ;) } } }
Default consent checkers
This library also provides two implementations of the ConsentCheckerInterface
, namely the DenyAllConsentChecker
and
GrantAllConsentChecker
. You can use these two to provide default consents if a consent management system isn't implemented.