setono/consent-contracts

Generic abstraction related to consent

Maintainers

👁 loevgaard

Package info

github.com/Setono/consent-contracts

pkg:composer/setono/consent-contracts

Statistics

Installs: 71 079

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2024-12-17 13:41 UTC

Requires

  • php: >=8.1

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 63d1ac62a500224d09066d7643ef90bf185f1039

consentgdpr

This package is auto-updated.

Last update: 2026-06-17 17:14:13 UTC


README

👁 Latest Version
👁 Software License
👁 Build Status
👁 Code Coverage

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.