Passed
Push — main ( 1d569c...efb346 )
by Axel
06:39
created

AcceptPoliciesHelper::getViewablePolicies()   B

Complexity

Conditions 9
Paths 160

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 9
nc 160
nop 1
dl 0
loc 12
rs 7.5555
c 0
b 0
f 0
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