Passed
Push — master ( 3a99ef...34868f )
by Roeland
09:54 queued 11s
created

ShareeList   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 10
c 3
b 0
f 1
dl 0
loc 23
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A xmlSerialize() 0 7 2
1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2019, Roeland Jago Douma <[email protected]>
5
 *
6
 * @author Roeland Jago Douma <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
25
namespace OCA\DAV\Connector\Sabre;
26
27
use OCP\Share\IShare;
28
use Sabre\Xml\Element;
29
use Sabre\Xml\Reader;
30
use Sabre\Xml\Writer;
31
use Sabre\Xml\XmlSerializable;
32
33
/**
34
 * This property contains multiple "sharee" elements, each containing a share sharee
35
 */
36
class ShareeList implements XmlSerializable {
37
	const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
38
39
	/** @var IShare[] */
40
	private $shares;
41
42
	public function __construct(array $shares) {
43
		$this->shares = $shares;
44
	}
45
46
	/**
47
	 * The xmlSerialize metod is called during xml writing.
48
	 *
49
	 * @param Writer $writer
50
	 * @return void
51
	 */
52
	function xmlSerialize(Writer $writer) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
53
		foreach ($this->shares as $share) {
54
			$writer->startElement('{' . self::NS_NEXTCLOUD . '}sharee');
55
			$writer->writeElement('{' . self::NS_NEXTCLOUD . '}id', $share->getSharedWith());
56
			$writer->writeElement('{' . self::NS_NEXTCLOUD . '}display-name', $share->getSharedWithDisplayName());
57
			$writer->writeElement('{' . self::NS_NEXTCLOUD . '}type', $share->getShareType());
58
			$writer->endElement();
59
		}
60
	}
61
}
62