Passed
Pull Request — master (#1516)
by Daniel
03:54
created

TShareCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 12
rs 10
c 2
b 0
f 0
cc 1
nc 1
nop 5
1
<?php
2
/**
3
 * @copyright Copyright (c) 2021 Daniel Rudolf <[email protected]>
4
 *
5
 * @author Daniel Rudolf <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Polls\Command\Share;
25
26
use OCA\Polls\Db\PollMapper;
27
use OCA\Polls\Db\ShareMapper;
28
use OCA\Polls\Service\ShareService;
29
use OCP\IGroup;
30
use OCP\IGroupManager;
31
use OCP\IUser;
32
use OCP\IUserManager;
33
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
0 ignored issues
show
Bug introduced by
The type Stecman\Component\Symfon...etion\CompletionContext was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
35
trait TShareCommand {
36
	/** @var PollMapper */
37
	private $pollMapper;
38
39
	/** @var ShareService */
40
	private $shareService;
41
42
	/** @var ShareMapper */
43
	private $shareMapper;
44
45
	/** @var IUserManager */
46
	private $userManager;
47
48
	/** @var IGroupManager */
49
	private $groupManager;
50
51
	public function __construct(PollMapper $pollMapper,
52
								ShareMapper $shareMapper,
53
								ShareService $shareService,
54
								IUserManager $userManager,
55
								IGroupManager $groupManager) {
56
		parent::__construct();
57
58
		$this->pollMapper = $pollMapper;
59
		$this->shareMapper = $shareMapper;
60
		$this->shareService = $shareService;
61
		$this->userManager = $userManager;
62
		$this->groupManager = $groupManager;
63
	}
64
65
	private function completeUserValues(CompletionContext $context): array {
66
		return array_map(function (IUser $user) {
67
			return $user->getUID();
68
		}, $this->userManager->search($context->getCurrentWord()));
69
	}
70
71
	private function completeGroupValues(CompletionContext $context): array {
72
		return array_map(function (IGroup $group) {
73
			return $group->getGID();
74
		}, $this->groupManager->search($context->getCurrentWord()));
75
	}
76
}
77