SyncRequestedEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 64
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isPersistAndFlush() 0 3 1
A __construct() 0 4 1
A getTagGroups() 0 3 1
A addTagGroup() 0 3 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\Event\Vacancy\Tag\Group;
17
18
use Symfony\Component\EventDispatcher\Event;
19
use Veslo\SanityBundle\Dto\Vacancy\Tag\GroupDto;
20
21
/**
22
 * Describes sanity tags group synchronization request
23
 */
24
class SyncRequestedEvent extends Event
25
{
26
    /**
27
     * Event name
28
     *
29
     * @const string
30
     */
31
    public const NAME = 'veslo.sanity.event.vacancy.tag.group.sync_requested';
32
33
    /**
34
     * Whenever a synchronizer should save resolved data in the local storage, default true
35
     *
36
     * @var bool
37
     */
38
    private $persistAndFlush;
39
40
    /**
41
     * List of sanity tag groups data filled up by synchronizers (new / modified groups)
42
     *
43
     * @var GroupDto[]
44
     */
45
    private $tagGroups;
46
47
    /**
48
     * SyncRequestedEvent constructor.
49
     *
50
     * @param bool $persistAndFlush Whenever a synchronizer should save resolved data in the local storage
51
     */
52
    public function __construct(bool $persistAndFlush = true)
53
    {
54
        $this->persistAndFlush = $persistAndFlush;
55
        $this->tagGroups       = [];
56
    }
57
58
    /**
59
     * Returns positive if a synchronizer should save resolved data in the local storage, negative otherwise
60
     *
61
     * @return bool
62
     */
63
    public function isPersistAndFlush(): bool
64
    {
65
        return $this->persistAndFlush;
66
    }
67
68
    /**
69
     * Returns sanity tag groups data which are marked as new / modified by synchronizer(s)
70
     *
71
     * @return GroupDto[]
72
     */
73
    public function getTagGroups(): array
74
    {
75
        return $this->tagGroups;
76
    }
77
78
    /**
79
     * Adds a sanity tags group data, marked as new / modified
80
     *
81
     * @param GroupDto $group Sanity tags group data
82
     *
83
     * @return void
84
     */
85
    public function addTagGroup(GroupDto $group): void
86
    {
87
        $this->tagGroups[] = $group;
88
    }
89
}
90