Completed
Push — master ( 09d563...df1aee )
by Matias
16s queued 11s
created

FaceRecognitionContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * @copyright Copyright (c) 2019-2020 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
30
use OCA\FaceRecognition\BackgroundJob\FaceRecognitionLogger;
31
32
/**
33
 * Simple class holding all information that tasks might need, so they can do their job.
34
 * It can also serve as a temporary storage of information flowing from one task to another.
35
 */
36
class FaceRecognitionContext {
37
	/** @var IUserManager */
38
	public $userManager;
39
40
	/** @var IConfig */
41
	public $config;
42
43
	/** @var FaceRecognitionLogger */
44
	public $logger;
45
46
	/** @var IUser|null */
47
	public $user;
48
49
	/** @var bool */
50
	public $verbose;
51
52
	/** @var array Associative array that can hold various data from tasks */
53
	public $propertyBag = [];
54
55
	/** @var bool True if we are running from command, false if we are running as background job */
56
	private $isRunningThroughCommand;
57
58 33
	public function __construct(IUserManager $userManager,
59
	                            IConfig      $config) {
60 33
		$this->userManager = $userManager;
61 33
		$this->config = $config;
62 33
		$this->isRunningThroughCommand = false;
63 33
	}
64
65
	public function isRunningThroughCommand(): bool {
66
		return $this->isRunningThroughCommand;
67
	}
68
69
	public function setRunningThroughCommand() {
70
		$this->isRunningThroughCommand = true;
71
	}
72
}