Completed
Push — improveTravis ( 69f7a5 )
by Matias
05:57
created

FaceRecognitionContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 50
ccs 8
cts 12
cp 0.6667
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isRunningThroughCommand() 0 2 1
A setRunningThroughCommand() 0 2 1
A __construct() 0 11 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017, Matias De lellis <[email protected]>
4
 * @copyright Copyright (c) 2018, Branko Kokanovic <[email protected]>
5
 *
6
 * @author Branko Kokanovic <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
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
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
namespace OCA\FaceRecognition\BackgroundJob;
25
26
use OCP\IConfig;
27
use OCP\IUser;
28
use OCP\IUserManager;
29
use OCP\App\IAppManager;
30
use OCP\Files\IRootFolder;
31
32
use OCA\FaceRecognition\BackgroundJob\FaceRecognitionLogger;
33
use OCA\FaceRecognition\Service\ModelService;
34
35
/**
36
 * Simple class holding all information that tasks might need, so they can do their job.
37
 * It can also serve as a temporary storage of information flowing from one task to another.
38
 */
39
class FaceRecognitionContext {
40
	/** @var IAppManager */
41
	public $appManager;
42
43
	/** @var IUserManager */
44
	public $userManager;
45
46
	/** @var IRootFolder */
47
	public $rootFolder;
48
49
	/** @var IConfig */
50
	public $config;
51
52
	/** @var ModelService */
53
	public $modelService;
54
55
	/** @var FaceRecognitionLogger */
56
	public $logger;
57
58
	/** @var IUser|null */
59
	public $user;
60
61
	/** @var bool */
62
	public $verbose;
63
64
	/** @var array Associative array that can hold various data from tasks */
65
	public $propertyBag = [];
66
67
	/** @var bool True if we are running from command, false if we are running as background job */
68
	private $isRunningThroughCommand;
69
70 34
	public function __construct(IAppManager  $appManager,
71
	                            IUserManager $userManager,
72
	                            IRootFolder  $rootFolder,
73
	                            IConfig      $config,
74
	                            ModelService $modelService) {
75 34
		$this->appManager = $appManager;
76 34
		$this->userManager = $userManager;
77 34
		$this->rootFolder = $rootFolder;
78 34
		$this->config = $config;
79 34
		$this->modelService = $modelService;
80 34
		$this->isRunningThroughCommand = false;
81 34
	}
82
83
	public function isRunningThroughCommand(): bool {
84
		return $this->isRunningThroughCommand;
85
	}
86
87
	public function setRunningThroughCommand() {
88
		$this->isRunningThroughCommand = true;
89
	}
90
}