Code Duplication    Length = 16-17 lines in 5 locations

lib/private/Activity/Manager.php 2 locations

@@ 113-129 (lines=17) @@
110
	/**
111
	 * @return \OCP\Activity\IConsumer[]
112
	 */
113
	protected function getConsumers() {
114
		if (!empty($this->consumers)) {
115
			return $this->consumers;
116
		}
117
118
		$this->consumers = [];
119
		foreach($this->consumersClosures as $consumer) {
120
			$c = $consumer();
121
			if ($c instanceof IConsumer) {
122
				$this->consumers[] = $c;
123
			} else {
124
				throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface');
125
			}
126
		}
127
128
		return $this->consumers;
129
	}
130
131
	/**
132
	 * @return \OCP\Activity\IExtension[]
@@ 134-150 (lines=17) @@
131
	/**
132
	 * @return \OCP\Activity\IExtension[]
133
	 */
134
	protected function getExtensions() {
135
		if (!empty($this->extensions)) {
136
			return $this->extensions;
137
		}
138
139
		$this->extensions = [];
140
		foreach($this->extensionsClosures as $extension) {
141
			$e = $extension();
142
			if ($e instanceof IExtension) {
143
				$this->extensions[] = $e;
144
			} else {
145
				throw new \InvalidArgumentException('The given extension does not implement the \OCP\Activity\IExtension interface');
146
			}
147
		}
148
149
		return $this->extensions;
150
	}
151
152
	/**
153
	 * Generates a new IEvent object

lib/private/Comments/Manager.php 1 location

@@ 977-992 (lines=16) @@
974
	 *
975
	 * @return \OCP\Comments\ICommentsEventHandler[]
976
	 */
977
	private function getEventHandlers() {
978
		if (!empty($this->eventHandlers)) {
979
			return $this->eventHandlers;
980
		}
981
982
		$this->eventHandlers = [];
983
		foreach ($this->eventHandlerClosures as $name => $closure) {
984
			$entity = $closure();
985
			if (!($entity instanceof ICommentsEventHandler)) {
986
				throw new \InvalidArgumentException('The given entity does not implement the ICommentsEntity interface');
987
			}
988
			$this->eventHandlers[$name] = $entity;
989
		}
990
991
		return $this->eventHandlers;
992
	}
993
994
	/**
995
	 * sends notifications to the registered entities

lib/private/Notification/Manager.php 2 locations

@@ 102-117 (lines=16) @@
99
	/**
100
	 * @return IApp[]
101
	 */
102
	protected function getApps(): array {
103
		if (!empty($this->apps)) {
104
			return $this->apps;
105
		}
106
107
		$this->apps = [];
108
		foreach ($this->appsClosures as $closure) {
109
			$app = $closure();
110
			if (!($app instanceof IApp)) {
111
				throw new \InvalidArgumentException('The given notification app does not implement the IApp interface');
112
			}
113
			$this->apps[] = $app;
114
		}
115
116
		return $this->apps;
117
	}
118
119
	/**
120
	 * @return INotifier[]
@@ 122-137 (lines=16) @@
119
	/**
120
	 * @return INotifier[]
121
	 */
122
	protected function getNotifiers(): array {
123
		if (!empty($this->notifiers)) {
124
			return $this->notifiers;
125
		}
126
127
		$this->notifiers = [];
128
		foreach ($this->notifiersClosures as $closure) {
129
			$notifier = $closure();
130
			if (!($notifier instanceof INotifier)) {
131
				throw new \InvalidArgumentException('The given notifier does not implement the INotifier interface');
132
			}
133
			$this->notifiers[] = $notifier;
134
		}
135
136
		return $this->notifiers;
137
	}
138
139
	/**
140
	 * @return array[]