Completed
Push — master ( 0b53f5...b7cd5d )
by Maxence
03:50 queued 01:53
created

RemoteController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 2
dl 0
loc 60
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A test() 0 3 1
A incoming() 0 7 2
A circles() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
6
/**
7
 * Circles - Bring cloud-users closer together.
8
 *
9
 * This file is licensed under the Affero General Public License version 3 or
10
 * later. See the COPYING file.
11
 *
12
 * @author Maxence Lange <[email protected]>
13
 * @copyright 2020
14
 * @license GNU AGPL version 3 or any later version
15
 *
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28
 *
29
 */
30
31
32
namespace OCA\Circles\Controller;
33
34
use daita\MySmallPhpTools\Exceptions\InvalidOriginException;
35
use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
36
use daita\MySmallPhpTools\Exceptions\SignatoryException;
37
use daita\MySmallPhpTools\Exceptions\SignatureException;
38
use daita\MySmallPhpTools\Traits\Nextcloud\nc21\TNC21Controller;
39
use daita\MySmallPhpTools\Traits\Nextcloud\nc21\TNC21Signature;
40
use Exception;
41
use OCA\Circles\Service\RemoteService;
42
use OCP\AppFramework\Controller;
43
use OCP\AppFramework\Http\DataResponse;
44
use OCP\IRequest;
45
46
47
/**
48
 * Class RemoteController
49
 *
50
 * @package OCA\Circles\Controller
51
 */
52
class RemoteController extends Controller {
53
54
55
	use TNC21Controller;
56
57
58
	/** @var RemoteService */
59
	private $remoteService;
60
61
62
	public function __construct(string $appName, IRequest $request, RemoteService $remoteService) {
63
		parent::__construct($appName, $request);
64
65
		$this->remoteService = $remoteService;
66
	}
67
68
69
	/**
70
	 * @PublicPage
71
	 * @NoCSRFRequired
72
	 *
73
	 * @return DataResponse
74
	 * @throws InvalidOriginException
75
	 * @throws MalformedArrayException
76
	 * @throws SignatoryException
77
	 * @throws SignatureException
78
	 */
79
	public function test() {
80
		return $this->successObj($this->remoteService->incomingTest());
81
	}
82
83
84
	/**
85
	 * @PublicPage
86
	 * @NoCSRFRequired
87
	 * @SignedRequest(signatory=toto)
88
	 */
89
	public function incoming() {
90
		try {
91
			return $this->success([]);
92
		} catch (Exception $e) {
93
			return $this->fail($e);
94
		}
95
	}
96
97
98
	/**
99
	 * @PublicPage
100
	 * @NoCSRFRequired
101
	 */
102
	public function circles() {
103
		$body = file_get_contents('php://input');
0 ignored issues
show
Unused Code introduced by
$body is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
104
105
		$circles = [];
106
107
		return $this->success($circles);
108
	}
109
110
111
}
112
113