AcceptPoliciesHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getActivePolicies() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\LegalBundle\Helper;
15
16
/**
17
 * Helper class to process acceptance of policies.
18
 */
19
class AcceptPoliciesHelper
20
{
21
    public function __construct(private readonly array $legalConfig)
22
    {
23
    }
24
25
    /**
26
     * Retrieves flags indicating which policies are active.
27
     *
28
     * @return array An array containing flags indicating whether each policy is active or not
29
     */
30
    public function getActivePolicies(): array
31
    {
32
        $policies = $this->legalConfig['policies'];
33
34
        return [
35
            'privacyPolicy' => $policies['privacy_policy']['enabled'],
36
            'termsOfUse' => $policies['terms_of_use']['enabled'],
37
            'tradeConditions' => $policies['trade_conditions']['enabled'],
38
            'cancellationRightPolicy' => $policies['cancellation_right_policy']['enabled'],
39
            'agePolicy' => 0 !== $this->legalConfig['minimum_age'],
40
        ];
41
    }
42
}
43