GetUsers   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setRequestData() 0 3 1
A __construct() 0 7 1
A execute() 0 14 2
1
<?php
2
/**
3
 * Copyright (c) 2014, Tobia De Koninck hey--at--ledfan.be
4
 * This file is licensed under the AGPL version 3 or later.
5
 * See the COPYING file.
6
 */
7
8
namespace OCA\Chat\OCH\Data;
9
10
use \OCA\Chat\OCH\ChatAPI;
11
use \OCA\Chat\App\Chat;
12
use \OCA\Chat\OCH\Db\UserMapper;
13
14
15
class GetUsers extends ChatAPI {
16
17
	/**
18
	 * @var $userMapper \OCA\Chat\OCH\Db\UserMapper
19
	 */
20
	private $userMapper;
21
22
	public function __construct(
23
		Chat $app,
24
		UserMapper $userMapper
25
	){
26
		$this->app = $app;
0 ignored issues
show
Bug introduced by
The property app does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
27
		$this->userMapper = $userMapper;
28
	}
29
30
	/*
31
	 * @param $requestData['user'] String user id of the client
32
	 * @param $requestData['convid'] String session_id of the client
33
	 */
34
	public function setRequestData(array $requestData){
35
		$this->requestData = $requestData;
36
	}
37
38
	public function execute(){
39
		$contacts = $this->app->getContacts();
40
		$contacts = $contacts['contactsObj'];
41
		
42
		$users = $this->userMapper->findUsersInConv($this->requestData['conv_id']);
43
		
44
		$return = array();
45
		foreach($users as $user){
46
			$return[] = $contacts[$user];
47
		}
48
49
		// Note: users are full contacts
50
		return array("users" => $return);
51
	}
52
}
53