Completed
Push — ezp_30981_content_info_proxy ( 5d5afd...47f956 )
by
unknown
15:40
created

VersionPublishingEvaluator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A accept() 0 4 1
A evaluate() 0 11 2
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\Limitation\LanguageLimitation;
10
11
use eZ\Publish\API\Repository\Values\User\Limitation;
12
use eZ\Publish\Core\Limitation\LanguageLimitationType;
13
use eZ\Publish\SPI\Limitation\Target;
14
15
/**
16
 * @internal for internal use by LanguageLimitation
17
 */
18
final class VersionPublishingEvaluator implements VersionTargetEvaluator
19
{
20
    public function accept(Target\Version $targetVersion): bool
21
    {
22
        return !empty($targetVersion->forPublishLanguageCodesList);
23
    }
24
25
    /**
26
     * Evaluate publishing a specific translation of a Version.
27
     */
28
    public function evaluate(Target\Version $targetVersion, Limitation $limitationValue): ?bool
29
    {
30
        $diff = array_diff(
31
            $targetVersion->forPublishLanguageCodesList,
32
            $limitationValue->limitationValues
33
        );
34
35
        return empty($diff)
36
            ? LanguageLimitationType::ACCESS_GRANTED
37
            : LanguageLimitationType::ACCESS_DENIED;
38
    }
39
}
40