PatchUserGroups   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateUserGroups() 0 8 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/DTO/Traits/PatchUserGroups.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\DTO\Traits;
10
11
use App\Entity\Interfaces\UserGroupAwareInterface;
12
use App\Entity\UserGroup as UserGroupEntity;
13
use function array_map;
14
15
/**
16
 * Trait PatchUserGroups
17
 *
18
 * @package App\DTO\Traits
19
 * @author TLe, Tarmo Leppänen <[email protected]>
20
 */
21
trait PatchUserGroups
22
{
23
    /**
24
     * Method to patch entity user groups.
25
     *
26
     * @param array<int, UserGroupEntity> $value
27
     */
28 2
    protected function updateUserGroups(UserGroupAwareInterface $entity, array $value): self
29
    {
30 2
        array_map(
31 2
            static fn (UserGroupEntity $userGroup): UserGroupAwareInterface => $entity->addUserGroup($userGroup),
32 2
            $value,
33 2
        );
34
35 2
        return $this;
36
    }
37
}
38