Completed
Push — master ( 7d58bb...687957 )
by Morris
17:49
created

Files::create()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 2
nop 1
dl 13
loc 13
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Lukas Reschke <[email protected]>
4
 *
5
 * @author Lukas Reschke <[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\AdminAudit\Actions;
25
26
/**
27
 * Class Files logs the actions to files
28
 *
29
 * @package OCA\AdminAudit\Actions
30
 */
31
class Files extends Action {
32
	/**
33
	 * Logs file read actions
34
	 *
35
	 * @param array $params
36
	 */
37
	public function read(array $params) {
38
		$this->log(
39
			'File accessed: "%s"',
40
			$params,
41
			[
42
				'path',
43
			]
44
		);
45
	}
46
47
	/**
48
	 * Logs rename actions of files
49
	 *
50
	 * @param array $params
51
	 */
52
	public function rename(array $params) {
53
		$this->log(
54
			'File renamed: "%s" to "%s"',
55
			$params,
56
			[
57
				'oldpath',
58
				'newpath',
59
			]
60
		);
61
	}
62
63
	/**
64
	 * Logs creation of files
65
	 *
66
	 * @param array $params
67
	 */
68 View Code Duplication
	public function create(array $params) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
		if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) {
70
			return;
71
		}
72
73
		$this->log(
74
			'File created: "%s"',
75
			$params,
76
			[
77
				'path',
78
			]
79
		);
80
	}
81
82
	/**
83
	 * Logs copying of files
84
	 *
85
	 * @param array $params
86
	 */
87
	public function copy(array $params) {
88
		$this->log(
89
			'File copied: "%s" to "%s"',
90
			$params,
91
			[
92
				'oldpath',
93
				'newpath',
94
			]
95
		);
96
	}
97
98
	/**
99
	 * Logs writing of files
100
	 *
101
	 * @param array $params
102
	 */
103 View Code Duplication
	public function write(array $params) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
104
		if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) {
105
			return;
106
		}
107
108
		$this->log(
109
			'File written to: "%s"',
110
			$params,
111
			[
112
				'path',
113
			]
114
		);
115
	}
116
117
	/**
118
	 * Logs update of files
119
	 *
120
	 * @param array $params
121
	 */
122
	public function update(array $params) {
123
		$this->log(
124
			'File updated: "%s"',
125
			$params,
126
			[
127
				'path',
128
			]
129
		);
130
	}
131
132
	/**
133
	 * Logs deletions of files
134
	 *
135
	 * @param array $params
136
	 */
137
	public function delete(array $params) {
138
		$this->log(
139
			'File deleted: "%s"',
140
			$params,
141
			[
142
				'path',
143
			]
144
		);
145
	}
146
147
	/**
148
	 * Logs preview access to a file
149
	 *
150
	 * @param array $params
151
	 */
152
	public function preview(array $params) {
153
		$this->log(
154
			'Preview accessed: "%s" (width: "%s", height: "%s" crop: "%s", mode: "%s")',
155
			$params,
156
			[
157
				'path',
158
				'width',
159
				'height',
160
				'crop',
161
				'mode'
162
			]
163
		);
164
	}
165
}
166