Passed
Push — master ( 8f4e6f...2bd98d )
by Morris
14:37 queued 02:45
created

RootCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2016, ownCloud, Inc.
5
 *
6
 * @author Lukas Reschke <[email protected]>
7
 * @author Thomas Müller <[email protected]>
8
 *
9
 * @license AGPL-3.0
10
 *
11
 * This code is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License, version 3,
13
 * as published by the Free Software Foundation.
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, version 3,
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
22
 *
23
 */
24
namespace OCA\DAV\Upload;
25
26
use Sabre\DAVACL\AbstractPrincipalCollection;
27
use Sabre\DAVACL\PrincipalBackend;
28
29
class RootCollection extends AbstractPrincipalCollection {
30
31
	/** @var CleanupService */
32
	private $cleanupService;
33
34
	public function __construct(PrincipalBackend\BackendInterface $principalBackend,
35
								string $principalPrefix,
36
								CleanupService $cleanupService) {
37
		parent::__construct($principalBackend, $principalPrefix);
38
		$this->cleanupService = $cleanupService;
39
	}
40
41
	/**
42
	 * @inheritdoc
43
	 */
44
	public function getChildForPrincipal(array $principalInfo): UploadHome {
45
		return new UploadHome($principalInfo, $this->cleanupService);
0 ignored issues
show
Bug Best Practice introduced by
The expression return new OCA\DAV\Uploa... $this->cleanupService) returns the type OCA\DAV\Upload\UploadHome which is incompatible with the return type mandated by Sabre\DAVACL\AbstractPri...:getChildForPrincipal() of Sabre\DAVACL\IPrincipal.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
46
	}
47
48
	/**
49
	 * @inheritdoc
50
	 */
51
	public function getName(): string {
52
		return 'uploads';
53
	}
54
55
}
56