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

FaceRecognitionContext::isRunningThroughCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
}