GroupValidationTrait::includeBasedOnGroup()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 5
nc 3
nop 2
crap 3
1
<?php
2
3
namespace Happyr\SerializerBundle\Normalizer;
4
5
/**
6
 * @author Tobias Nyholm <[email protected]>
7
 */
8
trait GroupValidationTrait
9
{
10
    /**
11
     * @param array $context
12
     * @param array $groups
13
     *
14
     * @return bool
15
     */
16 2
    protected function includeBasedOnGroup(array $context, array $groups)
17
    {
18 2
        foreach ($context['groups'] as $group) {
19 2
            if (in_array($group, $groups)) {
20 2
                return true;
21
            }
22 2
        }
23
24 2
        return false;
25
    }
26
}
27