Completed
Push — master ( 3918b2...1f63e3 )
by Morris
19s queued 10s
created

GroupDeleted   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
6
/**
7
 * Circles - Bring cloud-users closer together.
8
 *
9
 * This file is licensed under the Affero General Public License version 3 or
10
 * later. See the COPYING file.
11
 *
12
 * @author Maxence Lange <[email protected]>
13
 * @copyright 2020
14
 * @license GNU AGPL version 3 or any later version
15
 *
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28
 *
29
 */
30
31
32
namespace OCA\Circles\Listeners;
33
34
use OCA\Circles\Service\GroupsService;
35
use OCP\EventDispatcher\Event;
36
use OCP\EventDispatcher\IEventListener;
37
use OCP\Group\Events\GroupDeletedEvent;
38
39
40
/**
41
 * Class GroupDeleted
42
 *
43
 * @package OCA\Circles\Events
44
 */
45
class GroupDeleted implements IEventListener {
46
47
48
	/** @var GroupsService */
49
	private $groupsService;
50
51
52
	/**
53
	 * GroupDeleted constructor.
54
	 *
55
	 * @param GroupsService $groupsService
56
	 */
57
	public function __construct(GroupsService $groupsService) {
58
		$this->groupsService = $groupsService;
59
	}
60
61
62
	/**
63
	 * @param Event $event
64
	 */
65
	public function handle(Event $event): void {
66
		if (!($event instanceof GroupDeletedEvent)) {
0 ignored issues
show
Bug introduced by
The class OCP\Group\Events\GroupDeletedEvent does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
67
			return;
68
		}
69
70
		$group = $event->getGroup();
71
		$groupId = $group->getGID();
72
		$this->groupsService->onGroupRemoved($groupId);
73
	}
74
75
}
76
77