Rule   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 69
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 11 1
1
<?php
2
/**
3
 * Copyright (c) 2015 Victor Dubiniuk <[email protected]>
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later.
6
 * See the COPYING-README file.
7
 */
8
9
namespace OCA\Files_Antivirus\Db;
10
11
use OCP\AppFramework\Db\Entity;
12
use JsonSerializable;
13
14
/**
15
 * Class Rule
16
 *
17
 * @package OCA\Files_Antivirus\Db
18
 *
19
 * @method setStatusType(int $type)
20
 * @method setDescription(string $description)
21
 * @method setStatus(int $status)
22
 * @method setResult(int $result)
23
 * @method setMatch(string $mach)
24
 */
25
class Rule extends Entity implements JsonSerializable {
26
	
27
	/*
28
	 * Rule needs to be validated by the exit code returned by scanner
29
	 */
30
	public const RULE_TYPE_CODE = 1;
31
	
32
	/*
33
	 * Rule needs to be validated by parsing the output returned by scanner with regexp
34
	 */
35
	public const RULE_TYPE_MATCH = 2;
36
37
	/**
38
	 *
39
	 * @var int groupId - used for sorting
40
	 */
41
	protected $groupId;
42
	
43
	/**
44
	 *
45
	 * @var int statusType - RULE_TYPE_CODE or RULE_TYPE_MATCH defines whether
46
	 *   rule should be checked by the shell exit code or regexp
47
	 */
48
	protected $statusType;
49
	
50
	/**
51
	 *
52
	 * @var int result - shell exit code for rules
53
	 *   of the type RULE_TYPE_CODE, 0 otherwise
54
	 */
55
	protected $result;
56
	
57
	/**
58
	 *
59
	 * @var string match - regexp to match for rules
60
	 *   of the type RULE_TYPE_MATCH, '' otherwise
61
	 */
62
	protected $match;
63
	
64
	/**
65
	 *
66
	 * @var string description - shell exit code meaning for rules
67
	 *   of the type RULE_TYPE_CODE, '' otherwise
68
	 */
69
	protected $description;
70
	
71
	/**
72
	 *
73
	 * @var int status - file check status. SCANRESULT_UNCHECKED, SCANRESULT_INFECTED,
74
	 *   SCANRESULT_CLEAN are matching Unknown, Infected and Clean files accordingly.
75
	 */
76
	protected $status;
77
78
	/**
79
	 * Pack data into json
80
	 * @return array
81
	 */
82 1
	public function jsonSerialize() {
83
		return [
84 1
			'id' => $this->id,
85 1
			'group_id' => $this->groupId,
86 1
			'status_type' => $this->statusType,
87 1
			'result' => $this->result,
88 1
			'match' => $this->match,
89 1
			'description' => $this->description,
90 1
			'status' => $this->status
91
		];
92
	}
93
}
94