XMPP   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 3 1
A getDisplayName() 0 3 1
A getHelp() 0 3 1
B getInitConvs() 0 25 4
A getProtocols() 0 5 1
A getDefaultConfig() 0 7 1
1
<?php
2
3
namespace OCA\Chat\XMPP;
4
5
use \OCA\Chat\IBackend;
6
use \OCA\Chat\App\Chat;
7
use \OCA\Chat\AbstractBackend;
8
use \OCA\Chat\Db\ConfigMapper;
9
use \OCP\IConfig;
10
11
class XMPP extends AbstractBackend implements IBackend {
12
13
	private $app;
14
15
	public function __construct(ConfigMapper $configMapper, IConfig $config, Chat $app){
16
		parent::__construct($configMapper, $config);
17
		$this->app = $app;
18
	}
19
20
	public function getId(){
21
		return 'xmpp';
22
	}
23
24
	public function getInitConvs(){
25
		$contacts = $this->app->getContacts();
26
		$contacts = $contacts['contacts'];
27
		$currentUser = $this->app->getCurrentUser();
28
		$currentUserId = $currentUser['id'];
29
		$initConvs = array();
30
		foreach($contacts as $contact) {
31
			foreach ($contact['backends'] as $backend) {
32
				if ($backend['id'] === 'xmpp') {
33
					$jid = $backend['value'];
34
					$initConvs[$jid] = array(
35
						"id" => $jid,
36
						"users" => array(
37
							$contact['id'],
38
							$currentUserId
39
						),
40
						"backend" => 'xmpp',
41
						"messages" => array(),
42
						"files" => array()
43
					);
44
				}
45
			}
46
		}
47
		return $initConvs;
48
	}
49
50
	public function getDisplayName(){
51
		return 'XMPP';
52
	}
53
54
	public function getProtocols(){
55
		return array(
56
			'xmpp'
57
		);
58
	}
59
60
	public function getDefaultConfig(){
61
		return array(
62
			'jid' => null,
63
			"password" => null,
64
			"bosh_url" => null
65
		);
66
	}
67
68
69
	public function getHelp(){
70
		return '';
71
	}
72
}