Passed
Push — devel-3.0 ( 543c48...5b8639 )
by Rubén
03:28
created

AccountBulkRequest::getAccountRequestForId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * sysPass
4
 *
5
 * @author    nuxsmin
6
 * @link      https://syspass.org
7
 * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
8
 *
9
 * This file is part of sysPass.
10
 *
11
 * sysPass is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation, either version 3 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * sysPass is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 *  along with sysPass.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
25
namespace SP\Services\Account;
26
27
28
/**
29
 * Class AccountBulkRequest
30
 *
31
 * @package SP\Services\Account
32
 */
33
final class AccountBulkRequest
34
{
35
    /**
36
     * @var array
37
     */
38
    private $itemsId;
39
    /**
40
     * @var AccountRequest
41
     */
42
    private $accountRequest;
43
    /**
44
     * @var bool
45
     */
46
    private $deleteHistory = false;
47
48
    /**
49
     * AccountBulkRequest constructor.
50
     *
51
     * @param array          $itemsId
52
     * @param AccountRequest $accountRequest
53
     */
54
    public function __construct(array $itemsId, AccountRequest $accountRequest)
55
    {
56
        $this->itemsId = $itemsId;
57
        $this->accountRequest = $accountRequest;
58
59
        $this->setUp();
60
    }
61
62
    private function setUp()
63
    {
64
        $this->accountRequest->changeUserGroup = $this->accountRequest->userGroupId > 0;
65
        $this->accountRequest->changePermissions = true;
66
    }
67
68
    /**
69
     * @return bool
70
     */
71
    public function isDeleteHistory(): bool
72
    {
73
        return $this->deleteHistory;
74
    }
75
76
    /**
77
     * @param bool $deleteHistory
78
     */
79
    public function setDeleteHistory(bool $deleteHistory)
80
    {
81
        $this->deleteHistory = $deleteHistory;
82
    }
83
84
    /**
85
     * @return array
86
     */
87
    public function getItemsId(): array
88
    {
89
        return $this->itemsId;
90
    }
91
92
    /**
93
     * @param int $id
94
     *
95
     * @return AccountRequest
96
     */
97
    public function getAccountRequestForId(int $id): AccountRequest
98
    {
99
        $request = clone $this->accountRequest;
100
        $request->id = $id;
101
102
        return $request;
103
    }
104
}