Passed
Push — master ( 692da9...451f70 )
by Robin
13:23 queued 15s
created

LazyStorageMountInfo::getMountProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Robin Appelman <[email protected]>
6
 *
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program. If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
namespace OC\Files\Config;
23
24
use OCP\Files\Mount\IMountPoint;
25
use OCP\IUser;
26
27
class LazyStorageMountInfo extends CachedMountInfo {
28
	/** @var IMountPoint */
29
	private $mount;
30
31
	/**
32
	 * CachedMountInfo constructor.
33
	 *
34
	 * @param IUser $user
35
	 * @param IMountPoint $mount
36
	 */
37
	public function __construct(IUser $user, IMountPoint $mount) {
38
		$this->user = $user;
39
		$this->mount = $mount;
40
	}
41
42
	/**
43
	 * @return int the numeric storage id of the mount
44
	 */
45
	public function getStorageId() {
46
		if (!$this->storageId) {
47
			$this->storageId = $this->mount->getNumericStorageId();
48
		}
49
		return parent::getStorageId();
50
	}
51
52
	/**
53
	 * @return int the fileid of the root of the mount
54
	 */
55
	public function getRootId() {
56
		if (!$this->rootId) {
57
			$this->rootId = $this->mount->getStorageRootId();
58
		}
59
		return parent::getRootId();
60
	}
61
62
	/**
63
	 * @return string the mount point of the mount for the user
64
	 */
65
	public function getMountPoint() {
66
		if (!$this->mountPoint) {
67
			$this->mountPoint = $this->mount->getMountPoint();
68
		}
69
		return parent::getMountPoint();
70
	}
71
72
	public function getMountId() {
73
		return $this->mount->getMountId();
74
	}
75
76
	/**
77
	 * Get the internal path (within the storage) of the root of the mount
78
	 *
79
	 * @return string
80
	 */
81
	public function getRootInternalPath() {
82
		return $this->mount->getInternalPath($this->mount->getMountPoint());
83
	}
84
85
	public function getMountProvider(): string {
86
		return $this->mount->getMountProvider();
87
	}
88
}
89