Completed
Push — exception_in_tasks ( 7463cd...3899e4 )
by Branko
01:58
created

PersonController::updateNameV2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
namespace OCA\FaceRecognition\Controller;
3
4
use OCP\IRequest;
5
use OCP\Files\IRootFolder;
6
use OCP\AppFramework\Http;
7
use OCP\AppFramework\Http\DataResponse;
8
use OCP\AppFramework\Http\JSONResponse;
9
use OCP\AppFramework\Http\DataDisplayResponse;
10
use OCP\AppFramework\Controller;
11
12
use OCA\FaceRecognition\Db\Face;
13
use OCA\FaceRecognition\Db\FaceMapper;
14
15
class PersonController extends Controller {
16
17
	private $rootFolder;
18
	private $faceMapper;
19
	private $userId;
20
21 View Code Duplication
	public function __construct($AppName, IRequest $request, IRootFolder $rootFolder, FaceMapper $facemapper, $UserId) {
22
		parent::__construct($AppName, $request);
23
		$this->rootFolder = $rootFolder;
24
		$this->faceMapper = $facemapper;
25
		$this->userId = $UserId;
26
	}
27
28
	/**
29
	 * @NoAdminRequired
30
	 */
31
	public function index() {
32
		$resp = array();
33
		$groups = $this->faceMapper->getGroups($this->userId);
34
		foreach ($groups as $group) {
35
			$resp[$group->getName()] = $this->faceMapper->findAllNamed($this->userId, $group->getName(), 12);
36
		}
37
		return new DataResponse($resp);
38
	}
39
40
	/**
41
	 * @NoAdminRequired
42
	 *
43
	 * @param string $name
44
	 */
45
	public function getFaces($name) {
46
		$faces = $this->faceMapper->findAllNamed($this->userId, $name);
47
		return new DataResponse($faces);
48
	}
49
50
	/**
51
	 * @NoAdminRequired
52
	 *
53
	 * @param string $oldName
0 ignored issues
show
Bug introduced by
There is no parameter named $oldName. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
54
	 * @param string $newName
55
	 */
56
	public function updateName($name, $newName) {
57
		$faces = $this->faceMapper->findAllNamed($this->userId, $name);
58
		foreach ($faces as $face) {
59
			$face->setName($newName);
60
			$this->faceMapper->update($face);
61
		}
62
		$newFaces = $this->faceMapper->findAllNamed($this->userId, $newName);
63
		return new DataResponse($newFaces);
64
	}
65
66
}
67