Passed
Push — self-contained-model ( 34afa8...32b4da )
by Matias
04:08
created

ModelManager::getModel()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 13
ccs 0
cts 13
cp 0
crap 12
rs 9.9
1
<?php
2
/**
3
 * @copyright Copyright (c) 2020, Matias De lellis <[email protected]>
4
 *
5
 * @author Matias De lellis <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\FaceRecognition\Model;
25
26
use OCP\IConfig;
27
use OCP\Files\IAppData;
28
use OCP\Files\IRootFolder;
29
use OCP\Files\NotFoundException;
30
31
use OCA\FaceRecognition\Model\DlibCnnModel;
32
33
use OCA\FaceRecognition\Model\DlibCnn68Model;
34
use OCA\FaceRecognition\Model\DlibCnn5Model;
35
36
class ModelManager {
37
38
	/** @var DlibCnn5Model */
39
	private $dlibCnn5Model;
40
41
	/** @var DlibCnn68Model */
42
	private $dlibCnn68Model;
43
44
	/**
45
	 * @param DlibCnn5Model $model
46
	 * @param DlibCnn68Model $model
47
	 */
48
	public function __construct(DlibCnn5Model  $dlibCnn5Model,
49
	                            DlibCnn68Model $dlibCnn68Model)
50
	{
51
		$this->dlibCnn5Model  = $dlibCnn5Model;
52
		$this->dlibCnn68Model = $dlibCnn68Model;
53
	}
54
55
	/**
56
	 * @return DlibCnnModel
57
	 */
58
	public function getModel(int $version): DlibCnnModel {
59
		switch ($version) {
60
			case 1:
61
				$model = $this->dlibCnn5Model;
62
				break;
63
			case 2:
64
				$model = $this->dlibCnn68Model;
65
				break;
66
			default:
67
				$model = null;
68
				break;
69
		}
70
		return $model;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $model could return the type null which is incompatible with the type-hinted return OCA\FaceRecognition\Model\DlibCnnModel. Consider adding an additional type-check to rule them out.
Loading history...
71
	}
72
73
}