ValidationStateProviderStrategy   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getValidationGroupsForSubject() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) 2019, Wesley O. Nichols
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Wesnick\WorkflowBundle\Validation;
13
14
use Symfony\Component\Workflow\Transition;
15
use Symfony\Component\Workflow\Workflow;
16
17
/**
18
 * Class ValidationStateProviderStrategy.
19
 *
20
 * @author Wesley O. Nichols <[email protected]>
21
 */
22
class ValidationStateProviderStrategy implements WorkflowValidationStrategyInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getValidationGroupsForSubject($subject, Workflow $workflow, Transition $transition): array
28
    {
29
        $groups = [];
30
31
        if ($subject instanceof ValidationStateProviderInterface) {
32
            foreach ($transition->getTos() as $state) {
33
                $groups = array_merge($groups, $subject->getGroupSequenceForState($state, $workflow->getName()));
34
            }
35
        }
36
37
        return $groups;
38
    }
39
}
40