MinistryOfTruth::convertTagGroup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 14
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\SanityBundle\Vacancy\Tag\Group\Provider\DataConverter;
17
18
use SymfonyDoge\MinistryOfTruthClient\Dto\Response\Tag\Group\ContentDto as GroupData;
19
use Veslo\SanityBundle\Dto\Vacancy\Tag\GroupDto;
20
21
/**
22
 * Converts sanity tag groups data from external format to local data transfer objects
23
 */
24
class MinistryOfTruth
25
{
26
    /**
27
     * Returns array of sanity tag groups (DTOs) created by specified data in format of integration layer
28
     *
29
     * @param GroupData[] $groups Array of sanity tags group structures from external microservice
30
     *
31
     * @return GroupDto[]
32
     */
33
    public function convertTagGroups(array $groups): array
34
    {
35
        $groupDtoArray = [];
36
37
        foreach ($groups as $group) {
38
            $groupDtoArray[] = $this->convertTagGroup($group);
39
        }
40
41
        return $groupDtoArray;
42
    }
43
44
    /**
45
     * Returns sanity tags group dto created by specified data in format of integration layer
46
     *
47
     * @param GroupData $group Sanity tags group structure from external microservice
48
     *
49
     * @return GroupDto
50
     */
51
    public function convertTagGroup(GroupData $group): GroupDto
52
    {
53
        $groupDto = new GroupDto();
54
55
        $groupName = $group->getName();
56
        $groupDto->setName($groupName);
57
58
        $groupDescription = $group->getDescription();
59
        $groupDto->setDescription($groupDescription);
60
61
        $groupColor = $group->getColor();
62
        $groupDto->setColor($groupColor);
63
64
        return $groupDto;
65
    }
66
}
67