Skip to content

Commit

Permalink
Upgrade library to match wording in 'mainstream' CMP platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Dec 17, 2024
1 parent 869562a commit 096d7b8
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 60 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

53 changes: 23 additions & 30 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "highest"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Setup PHP, with composer and extensions"
uses: "shivammathur/setup-php@v2"
Expand All @@ -31,7 +31,7 @@ jobs:
coverage: "none"

- name: "Install composer dependencies"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"

Expand All @@ -52,36 +52,32 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"

dependencies:
- "lowest"
- "highest"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Setup PHP, with composer and extensions"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: "composer-require-checker, composer-unused"

- name: "Install composer dependencies"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run maglnet/composer-require-checker"
run: "composer-require-checker"

- name: "Run composer-unused/composer-unused"
run: "composer-unused || true" # todo remove when https://github.com/shivammathur/setup-php/issues/703 is fixed
- name: "Run dependency analysis"
run: "vendor/bin/composer-dependency-analyser"

static-code-analysis:
name: "Static Code Analysis"
Expand All @@ -91,18 +87,18 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"

dependencies:
- "lowest"
- "highest"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Setup PHP, with composer and extensions"
uses: "shivammathur/setup-php@v2"
Expand All @@ -111,7 +107,7 @@ jobs:
coverage: "none"

- name: "Install composer dependencies"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"

Expand All @@ -126,18 +122,18 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"

dependencies:
- "lowest"
- "highest"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Setup PHP, with composer and extensions"
uses: "shivammathur/setup-php@v2"
Expand All @@ -146,7 +142,7 @@ jobs:
coverage: "none"

- name: "Install composer dependencies"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"

Expand All @@ -161,33 +157,30 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.4"

dependencies:
- "highest"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Setup PHP, with composer and extensions"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for phpunit/phpunit"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""

- name: "Install composer dependencies"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Collect code coverage with pcov and phpunit/phpunit"
run: "vendor/bin/phpunit --coverage-clover=.build/logs/clover.xml"

- name: "Send code coverage report to Codecov.io"
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
run: "bash <(curl -s https://codecov.io/bash)"
uses: "codecov/codecov-action@v4"
with:
token: "${{ secrets.CODECOV_TOKEN }}"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Setono
Copyright (c) 2024 Setono

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"gdpr"
],
"require": {
"php": ">=7.4"
"php": ">=8.1"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18",
"setono/code-quality-pack": "^2.4"
"setono/code-quality-pack": "^2.4",
"shipmonk/composer-dependency-analyser": "^1.8"
},
"prefer-stable": true,
"autoload": {
Expand Down
12 changes: 6 additions & 6 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
$containerConfigurator->parameters()->set(Option::PATHS, [
'src', 'tests'
return static function (ECSConfig $config): void {
$config->import('vendor/sylius-labs/coding-standard/ecs.php');
$config->paths([
'src',
'tests',
]);
};
16 changes: 16 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
findUnusedPsalmSuppress="true"
findUnusedVariablesAndParams="true"
>
<projectFiles>
<directory name="src"/>
Expand All @@ -15,4 +19,16 @@
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<issueHandlers>
<DeprecatedConstant>
<errorLevel type="suppress">
<file name="src/Consents.php"/>
</errorLevel>
</DeprecatedConstant>
<DeprecatedClass>
<errorLevel type="suppress">
<file name="src/Consents.php"/>
</errorLevel>
</DeprecatedClass>
</issueHandlers>
</psalm>
4 changes: 4 additions & 0 deletions src/ConsentCheckerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@

interface ConsentCheckerInterface
{
/**
* You can define your own consent logic by implementing this interface,
* but it is recommended to use the values from Setono\Consent\DefaultConsents.
*/
public function isGranted(string $consent): bool;
}
11 changes: 10 additions & 1 deletion src/Consents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@

namespace Setono\Consent;

final class Consents
/**
* @deprecated since 1.1 and will be removed in 2.0. Use \Setono\Consent\DefaultConsents instead
*/
class Consents
{
public const CONSENT_MARKETING = 'marketing';

/**
* @deprecated since 1.1 and will be removed in 2.0. Use \Setono\Consent\DefaultConsents::CONSENT_PREFERENCES instead
*/
public const CONSENT_PREFERENCES = 'preferences';

/**
* @deprecated since 1.1 and will be removed in 2.0. Use \Setono\Consent\DefaultConsents::CONSENT_STATISTICAL instead
*/
public const CONSENT_STATISTICS = 'statistics';

/**
Expand Down
26 changes: 26 additions & 0 deletions src/DefaultConsents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace Setono\Consent;

final class DefaultConsents
{
public const CONSENT_FUNCTIONAL = 'functional';

public const CONSENT_MARKETING = 'marketing';

public const CONSENT_STATISTICAL = 'statistical';

/**
* @return list<string>
*/
public static function all(): array
{
return [
self::CONSENT_FUNCTIONAL,
self::CONSENT_MARKETING,
self::CONSENT_STATISTICAL,
];
}
}
6 changes: 3 additions & 3 deletions tests/ConsentsTest.php → tests/DefaultConsentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

use PHPUnit\Framework\TestCase;

final class ConsentsTest extends TestCase
final class DefaultConsentsTest extends TestCase
{
/**
* @test
*/
public function it_returns_all_consents(): void
{
$consents = Consents::all();
$consents = DefaultConsents::all();
self::assertCount(3, $consents);

foreach ([Consents::CONSENT_MARKETING, Consents::CONSENT_PREFERENCES, Consents::CONSENT_STATISTICS] as $consent) {
foreach ([DefaultConsents::CONSENT_MARKETING, DefaultConsents::CONSENT_FUNCTIONAL, DefaultConsents::CONSENT_STATISTICAL] as $consent) {
self::assertContains($consent, $consents);
}
}
Expand Down
7 changes: 4 additions & 3 deletions tests/DenyAllConsentCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ final class DenyAllConsentCheckerTest extends TestCase
{
/**
* @test
*
* @dataProvider getAllConsents
*/
public function it_denies_all(string $consent): void
Expand All @@ -24,9 +25,9 @@ public function it_denies_all(string $consent): void
public function getAllConsents(): array
{
return [
[Consents::CONSENT_MARKETING],
[Consents::CONSENT_PREFERENCES],
[Consents::CONSENT_STATISTICS],
[DefaultConsents::CONSENT_MARKETING],
[DefaultConsents::CONSENT_FUNCTIONAL],
[DefaultConsents::CONSENT_STATISTICAL],
['random'],
];
}
Expand Down
7 changes: 4 additions & 3 deletions tests/GrantAllConsentCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ final class GrantAllConsentCheckerTest extends TestCase
{
/**
* @test
*
* @dataProvider getAllConsents
*/
public function it_denies_all(string $consent): void
Expand All @@ -24,9 +25,9 @@ public function it_denies_all(string $consent): void
public function getAllConsents(): array
{
return [
[Consents::CONSENT_MARKETING],
[Consents::CONSENT_PREFERENCES],
[Consents::CONSENT_STATISTICS],
[DefaultConsents::CONSENT_MARKETING],
[DefaultConsents::CONSENT_FUNCTIONAL],
[DefaultConsents::CONSENT_STATISTICAL],
['random'],
];
}
Expand Down

0 comments on commit 096d7b8

Please sign in to comment.