GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#966)
by Tom
02:08
created

Requirement_Exec::test()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace HM\BackUpWordPress;
4
5
/**
6
 * An abstract requirement class, individual requirements should
7
 * extend this class
8
 */
9
abstract class Requirement {
10
11
	/**
12
	 * @var string
13
	 */
14
	protected $name = '';
15
16
	/**
17
	 * @return mixed
18
	 */
19
	abstract protected function test();
20
21
	/**
22
	 * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
23
	 */
24
	public function name() {
25
		return $this->name;
26
	}
27
28
	/**
29
	 * @return mixed|string
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
30
	 */
31
	public function result() {
32
33
		$test = $this->test();
34
35
		if ( is_string( $test ) && $test )
36
			return $test;
37
38
		if ( is_bool( $test ) || empty( $test ) ) {
39
40
			if ( $test ) {
41
				return 'Yes';
42
			}
43
44
			return 'No';
45
46
		}
47
48
		return var_export( $test, true );
49
50
	}
51
52
	public function raw_result() {
53
		return $this->test();
54
	}
55
56
}
57
58
/**
59
 * Class Requirement_Zip_Archive
60
 */
61
class Requirement_Zip_Archive extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
62
63
	/**
64
	 * @var string
65
	 */
66
	var $name = 'ZipArchive';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
67
68
	/**
69
	 * @return bool
70
	 */
71
	protected function test() {
72
73
		if ( class_exists( 'ZipArchive' ) ) {
1 ignored issue
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return class_exists('ZipArchive');.
Loading history...
74
			return true;
75
		}
76
77
		return false;
78
79
	}
80
81
}
82
Requirements::register( 'HM\BackUpWordPress\Requirement_Zip_Archive', 'PHP' );
83
84
/**
85
 * Class Requirement_Directory_Iterator_Follow_Symlinks
86
 *
87
 * Tests whether the FOLLOW_SYMLINKS class constant is available on Directory Iterator
88
 */
89
class Requirement_Directory_Iterator_Follow_Symlinks extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
90
91
	/**
92
	 * @var string
93
	 */
94
	var $name = 'DirectoryIterator FOLLOW_SYMLINKS';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
95
96
	/**
97
	 * @return bool
98
	 */
99
	protected function test() {
100
101
		if ( defined( 'RecursiveDirectoryIterator::FOLLOW_SYMLINKS' ) ) {
1 ignored issue
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return defined('Recursiv...tor::FOLLOW_SYMLINKS');.
Loading history...
102
			return true;
103
		}
104
105
		return false;
106
107
	}
108
109
}
110
Requirements::register( 'HM\BackUpWordPress\Requirement_Directory_Iterator_Follow_Symlinks', 'PHP' );
111
112
/**
113
 * Class Requirement_Zip_Command
114
 *
115
 * Tests whether the zip command is available and if it is what path it's available at
116
 */
117
class Requirement_Zip_Command_Path extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
118
119
	/**
120
	 * @var string
121
	 */
122
	var $name = 'zip command';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
123
124
	/**
125
	 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|false?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
126
	 */
127
	protected function test() {
128
129
		$backup = new Zip_File_Backup_Engine;
130
131
		return $backup->get_zip_executable_path();
132
133
	}
134
135
}
136
Requirements::register( 'HM\BackUpWordPress\Requirement_Zip_Command_Path', 'Server' );
137
138
/**
139
 * Class Requirement_Mysqldump_Command
140
 *
141
 * Tests whether the zip command is available and if it is what path it's available at
142
 */
143
class Requirement_Mysqldump_Command_Path extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
144
145
	/**
146
	 * @var string
147
	 */
148
	var $name = 'mysqldump command';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
149
150
	/**
151
	 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|false?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
152
	 */
153
	protected function test() {
154
155
		$backup = new Mysqldump_Database_Backup_Engine;
156
157
		return $backup->get_mysqldump_executable_path();
158
159
	}
160
161
}
162
Requirements::register( 'HM\BackUpWordPress\Requirement_Mysqldump_Command_Path', 'Server' );
163
164
/**
165
 * Class Requirement_PHP_User
166
 */
167
class Requirement_PHP_User extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
168
169
	/**
170
	 * @var string
171
	 */
172
	var $name = 'User';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
173
174
	/**
175
	 * @return string
176
	 */
177
	protected function test() {
178
179
		if ( ! Backup_Utilities::is_exec_available() ) {
180
			return '';
181
		}
182
183
		return shell_exec( 'whoami' );
184
185
	}
186
187
}
188
Requirements::register( 'HM\BackUpWordPress\Requirement_PHP_User', 'PHP' );
189
190
/**
191
 * Class Requirement_PHP_Group
192
 */
193
class Requirement_PHP_Group extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
194
195
	/**
196
	 * @var string
197
	 */
198
	var $name = 'Group[s]';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
199
200
	/**
201
	 * @return string
202
	 */
203
	protected function test() {
204
205
		if ( ! Backup_Utilities::is_exec_available() ) {
206
			return '';
207
		}
208
209
		return shell_exec( 'groups' );
210
211
	}
212
213
}
214
Requirements::register( 'HM\BackUpWordPress\Requirement_PHP_Group', 'PHP' );
215
216
/**
217
 * Class Requirement_PHP_Version
218
 */
219
class Requirement_PHP_Version extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
220
221
	/**
222
	 * @var string
223
	 */
224
	var $name = 'Version';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
225
226
	/**
227
	 * @return string
228
	 */
229
	protected function test() {
230
		return PHP_VERSION;
231
	}
232
233
}
234
Requirements::register( 'HM\BackUpWordPress\Requirement_PHP_Version', 'PHP' );
235
236
/**
237
 * Class Requirement_Cron_Array
238
 */
239
class Requirement_Cron_Array extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
240
241
	/**
242
	 * @var string
243
	 */
244
	var $name = 'Cron Array';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
245
246
	/**
247
	 * @return bool|mixed
248
	 */
249
	protected function test() {
250
251
		$cron = get_option( 'cron' );
252
253
		if ( ! $cron ) {
254
			return false;
255
		}
256
257
		return $cron;
258
259
	}
260
261
}
262
Requirements::register( 'HM\BackUpWordPress\Requirement_Cron_Array', 'Site' );
263
264
/**
265
 * Class Requirement_Cron_Array
266
 */
267
class Requirement_Language extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
268
269
	/**
270
	 * @var string
271
	 */
272
	var $name = 'Language';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
273
274
	/**
275
	 * @return bool|mixed
276
	 */
277
	protected function test() {
278
279
		// Since 4.0
280
		$language = get_option( 'WPLANG' );
281
282
		if ( $language ) {
283
			return $language;
284
		}
285
286
		if ( defined( 'WPLANG' ) && WPLANG ) {
287
			return WPLANG;
288
		}
289
290
		return 'en_US';
291
292
	}
293
294
}
295
Requirements::register( 'HM\BackUpWordPress\Requirement_Language', 'Site' );
296
297
/**
298
 * Class Requirement_Safe_Mode
299
 */
300
class Requirement_Safe_Mode extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
301
302
	/**
303
	 * @var string
304
	 */
305
	var $name = 'Safe Mode';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
306
307
	/**
308
	 * @return bool
309
	 */
310
	protected function test() {
311
		return Backup_Utilities::is_safe_mode_on();
312
	}
313
314
}
315
Requirements::register( 'HM\BackUpWordPress\Requirement_Safe_Mode', 'PHP' );
316
317
/**
318
 * Class Requirement_Shell_Exec
319
 */
320
class Requirement_Exec extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
321
322
	/**
323
	 * @var string
324
	 */
325
	var $name = 'Exec';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
326
327
	/**
328
	 * @return bool
329
	 */
330
	protected function test() {
331
		return Backup_Utilities::is_exec_available();
332
	}
333
334
}
335
Requirements::register( 'HM\BackUpWordPress\Requirement_Exec', 'PHP' );
336
337
/**
338
 * Class Requirement_Memory_Limit
339
 */
340
class Requirement_PHP_Memory_Limit extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
341
342
	/**
343
	 * @var string
344
	 */
345
	var $name = 'Memory Limit';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
346
347
	/**
348
	 * @return string
349
	 */
350
	protected function test() {
351
		return @ini_get( 'memory_limit' );
352
	}
353
354
}
355
Requirements::register( 'HM\BackUpWordPress\Requirement_PHP_Memory_Limit', 'PHP' );
356
357
/**
358
 * Class Requirement_Backup_Path
359
 */
360
class Requirement_Backup_Path extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
361
362
	/**
363
	 * @var string
364
	 */
365
	var $name = 'Backup Path';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
366
367
	/**
368
	 * @return string
369
	 */
370
	protected function test() {
371
		return Path::get_path();
372
	}
373
374
}
375
Requirements::register( 'HM\BackUpWordPress\Requirement_Backup_Path', 'Site' );
376
377
/**
378
 * Class Requirement_Backup_Path_Permissions
379
 */
380
class Requirement_Backup_Path_Permissions extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
381
382
	/**
383
	 * @var string
384
	 */
385
	var $name = 'Backup Path Permissions';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
386
387
	/**
388
	 * @return string
389
	 */
390
	protected function test() {
391
		return substr( sprintf( '%o', fileperms( Path::get_path() ) ), - 4 );
392
	}
393
394
}
395
Requirements::register( 'HM\BackUpWordPress\Requirement_Backup_Path_Permissions', 'Site' );
396
397
/**
398
 * Class Requirement_WP_CONTENT_DIR
399
 */
400
class Requirement_WP_CONTENT_DIR extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
401
402
	/**
403
	 * @var string
404
	 */
405
	var $name = 'WP_CONTENT_DIR';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
406
407
	/**
408
	 * @return string
409
	 */
410
	protected function test() {
411
		return WP_CONTENT_DIR;
412
	}
413
414
}
415
Requirements::register( 'HM\BackUpWordPress\Requirement_WP_CONTENT_DIR', 'Site' );
416
417
/**
418
 * Class Requirement_WP_CONTENT_DIR_Permissions
419
 */
420
class Requirement_WP_CONTENT_DIR_Permissions extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
421
422
	/**
423
	 * @var string
424
	 */
425
	var $name = 'WP_CONTENT_DIR Permissions';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
426
427
	/**
428
	 * @return string
429
	 */
430
	protected function test() {
431
		return substr( sprintf( '%o', fileperms( WP_CONTENT_DIR ) ), - 4 );
432
	}
433
434
}
435
Requirements::register( 'HM\BackUpWordPress\Requirement_WP_CONTENT_DIR_Permissions', 'Site' );
436
437
/**
438
 * Class Requirement_ABSPATH
439
 */
440
class Requirement_ABSPATH extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
441
442
	/**
443
	 * @var string
444
	 */
445
	var $name = 'ABSPATH';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
446
447
	/**
448
	 * @return string
449
	 */
450
	protected function test() {
451
		return ABSPATH;
452
	}
453
454
}
455
Requirements::register( 'HM\BackUpWordPress\Requirement_ABSPATH', 'Site' );
456
457
/**
458
 * Class Requirement_Backup_Root_Path
459
 */
460
class Requirement_Backup_Root_Path extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
461
462
	/**
463
	 * @var string
464
	 */
465
	var $name = 'Site Root Path';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
466
467
	/**
468
	 * @return string
469
	 */
470
	protected function test() {
471
		return Path::get_root();
472
	}
473
474
}
475
Requirements::register( 'HM\BackUpWordPress\Requirement_Backup_Root_Path', 'Site' );
476
477
/**
478
 * Class Requirement_Calculated_Size
479
 */
480
class Requirement_Calculated_Size extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
481
482
	/**
483
	 * @var string
484
	 */
485
	var $name = 'Calculated size of site';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
486
487
	/**
488
	 * @return array
489
	 */
490
	protected function test() {
491
492
		$backup_sizes = array();
493
494
		$schedules = Schedules::get_instance();
495
496
		foreach ( $schedules->get_schedules() as $schedule ) {
497
498
			$site_size = new Site_Size( $schedule->get_type(), $schedule->get_excludes() );
499
500
			if ( $site_size->is_site_size_cached() ) {
501
				$backup_sizes[ $schedule->get_type() ] = $site_size->get_formatted_site_size();
502
			}
503
504
		}
505
506
		return $backup_sizes;
507
508
	}
509
510
}
511
Requirements::register( 'HM\BackUpWordPress\Requirement_Calculated_Size', 'Site' );
512
513
/**
514
 * Class Requirement_WP_Cron_Test_Response
515
 */
516
class Requirement_WP_Cron_Test extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
517
518
	/**
519
	 * @var string
520
	 */
521
	var $name = 'WP Cron Test Failed';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
522
523
	/**
524
	 * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use boolean.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
525
	 */
526
	protected function test() {
527
		return (bool) get_option( 'hmbkp_wp_cron_test_failed' );
528
	}
529
530
}
531
Requirements::register( 'HM\BackUpWordPress\Requirement_WP_Cron_Test', 'Site' );
532
533
/**
534
 * Class Requirement_PHP_API
535
 */
536
class Requirement_PHP_API extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
537
538
	/**
539
	 * @var string
540
	 */
541
	var $name = 'Interface';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
542
543
	/**
544
	 * @return string
545
	 */
546
	protected function test() {
547
		return php_sapi_name();
548
	}
549
550
}
551
Requirements::register( 'HM\BackUpWordPress\Requirement_PHP_API', 'PHP' );
552
553
/**
554
 * Class Requirement_Server_Software
555
 */
556
class Requirement_Server_Software extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
557
558
	/**
559
	 * @var string
560
	 */
561
	var $name = 'Server';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
562
563
	/**
564
	 * @return bool
565
	 */
566
	protected function test() {
1 ignored issue
show
Coding Style introduced by
test uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
567
568
		if ( ! empty( $_SERVER['SERVER_SOFTWARE'] ) )
569
			return $_SERVER['SERVER_SOFTWARE'];
570
571
		return false;
572
573
	}
574
575
}
576
Requirements::register( 'HM\BackUpWordPress\Requirement_Server_Software', 'Server' );
577
578
/**
579
 * Class Requirement_Server_OS
580
 */
581
class Requirement_Server_OS extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
582
583
	/**
584
	 * @var string
585
	 */
586
	var $name = 'OS';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
587
588
	/**
589
	 * @return string
590
	 */
591
	protected function test() {
592
		return PHP_OS;
593
	}
594
595
}
596
Requirements::register( 'HM\BackUpWordPress\Requirement_Server_OS', 'Server' );
597
598
/**
599
 * Class Requirement_PHP_Disable_Functions
600
 */
601
class Requirement_PHP_Disable_Functions extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
602
603
	/**
604
	 * @var string
605
	 */
606
	var $name = 'Disabled Functions';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
607
608
	/**
609
	 * @return string
610
	 */
611
	protected function test() {
612
		return @ini_get( 'disable_functions' );
613
	}
614
615
}
616
Requirements::register( 'HM\BackUpWordPress\Requirement_PHP_Disable_Functions', 'PHP' );
617
618
/**
619
 * Class Requirement_PHP_Open_Basedir
620
 */
621
class Requirement_PHP_Open_Basedir extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
622
623
	/**
624
	 * @var string
625
	 */
626
	var $name = 'open_basedir';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
627
628
	/**
629
	 * @return string
630
	 */
631
	protected function test() {
632
		return @ini_get( 'open_basedir' );
633
	}
634
635
}
636
Requirements::register( 'HM\BackUpWordPress\Requirement_PHP_Open_Basedir', 'PHP' );
637
638
/* CONSTANTS */
639
640
/**
641
 * Class Requirement_Define_HMBKP_PATH
642
 */
643
class Requirement_Define_HMBKP_PATH extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
644
645
	/**
646
	 * @var string
647
	 */
648
	var $name = 'HMBKP_PATH';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
649
650
	/**
651
	 * @return string
652
	 */
653
	protected function test() {
654
		return defined( 'HMBKP_PATH' ) ? HMBKP_PATH : '';
655
	}
656
657
}
658
Requirements::register( 'HM\BackUpWordPress\Requirement_Define_HMBKP_PATH', 'constants' );
659
660
/**
661
 * Class Requirement_Define_HMBKP_ROOT
662
 */
663
class Requirement_Define_HMBKP_ROOT extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
664
665
	/**
666
	 * @var string
667
	 */
668
	var $name = 'HMBKP_ROOT';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
669
670
	/**
671
	 * @return string
672
	 */
673
	protected function test() {
674
		return defined( 'HMBKP_ROOT' ) ? HMBKP_ROOT : '';
675
	}
676
677
}
678
Requirements::register( 'HM\BackUpWordPress\Requirement_Define_HMBKP_ROOT', 'constants' );
679
680
/**
681
 * Class Requirement_Define_HMBKP_MYSQLDUMP_PATH
682
 */
683
class Requirement_Define_HMBKP_MYSQLDUMP_PATH extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
684
685
	/**
686
	 * @var string
687
	 */
688
	var $name = 'HMBKP_MYSQLDUMP_PATH';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
689
690
	/**
691
	 * @return string
692
	 */
693
	protected function test() {
694
		return defined( 'HMBKP_MYSQLDUMP_PATH' ) ? HMBKP_MYSQLDUMP_PATH : '';
695
	}
696
697
}
698
Requirements::register( 'HM\BackUpWordPress\Requirement_Define_HMBKP_MYSQLDUMP_PATH', 'constants' );
699
700
/**
701
 * Class Requirement_Define_HMBKP_ZIP_PATH
702
 */
703
class Requirement_Define_HMBKP_ZIP_PATH extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
704
705
	/**
706
	 * @var string
707
	 */
708
	var $name = 'HMBKP_ZIP_PATH';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
709
710
	/**
711
	 * @return string
712
	 */
713
	protected function test() {
714
		return defined( 'HMBKP_ZIP_PATH' ) ? HMBKP_ZIP_PATH : '';
715
	}
716
717
}
718
Requirements::register( 'HM\BackUpWordPress\Requirement_Define_HMBKP_ZIP_PATH', 'constants' );
719
720
/**
721
 * Class Requirement_Define_HMBKP_CAPABILITY
722
 */
723
class Requirement_Define_HMBKP_CAPABILITY extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
724
725
	/**
726
	 * @var string
727
	 */
728
	var $name = 'HMBKP_CAPABILITY';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
729
730
	/**
731
	 * @return string
732
	 */
733
	protected function test() {
734
		return defined( 'HMBKP_CAPABILITY' ) ? HMBKP_CAPABILITY : '';
735
	}
736
737
}
738
Requirements::register( 'HM\BackUpWordPress\Requirement_Define_HMBKP_CAPABILITY', 'constants' );
739
740
/**
741
 * Class Requirement_Define_HMBKP_EMAIL
742
 */
743
class Requirement_Define_HMBKP_EMAIL extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
744
745
	/**
746
	 * @var string
747
	 */
748
	var $name = 'HMBKP_EMAIL';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
749
750
	/**
751
	 * @return string
752
	 */
753
	protected function test() {
754
		return defined( 'HMBKP_EMAIL' ) ? HMBKP_EMAIL : '';
755
	}
756
757
}
758
Requirements::register( 'HM\BackUpWordPress\Requirement_Define_HMBKP_EMAIL', 'constants' );
759
760
/**
761
 * Class Requirement_Define_HMBKP_ATTACHMENT_MAX_FILESIZE
762
 */
763
class Requirement_Define_HMBKP_ATTACHMENT_MAX_FILESIZE extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
764
765
	/**
766
	 * @var string
767
	 */
768
	var $name = 'HMBKP_ATTACHMENT_MAX_FILESIZE';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
769
770
	/**
771
	 * @return string
772
	 */
773
	protected function test() {
774
		return defined( 'HMBKP_ATTACHMENT_MAX_FILESIZE' ) ? HMBKP_ATTACHMENT_MAX_FILESIZE : '';
775
	}
776
777
}
778
Requirements::register( 'HM\BackUpWordPress\Requirement_Define_HMBKP_ATTACHMENT_MAX_FILESIZE', 'constants' );
779
780
/**
781
 * Class Requirement_Define_HMBKP_EXCLUDE
782
 */
783
class Requirement_Define_HMBKP_EXCLUDE extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
784
785
	/**
786
	 * @var string
787
	 */
788
	var $name = 'HMBKP_EXCLUDE';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
789
790
	/**
791
	 * @return string
792
	 */
793
	protected function test() {
794
		return defined( 'HMBKP_EXCLUDE' ) ? HMBKP_EXCLUDE : '';
795
	}
796
797
}
798
Requirements::register( 'HM\BackUpWordPress\Requirement_Define_HMBKP_EXCLUDE', 'constants' );
799
800
class Requirement_Active_Plugins extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
801
802
	var $name = 'Active Plugins';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
803
804
	protected function test(){
805
		return get_option( 'active_plugins' );
806
	}
807
808
}
809
Requirements::register( 'HM\BackUpWordPress\Requirement_Active_Plugins', 'Site' );
810
811
class Requirement_Home_Url extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
812
813
	var $name = 'Home URL';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
814
815
	protected function test(){
816
		return home_url();
817
	}
818
819
}
820
Requirements::register( 'HM\BackUpWordPress\Requirement_Home_Url', 'Site' );
821
822
class Requirement_Site_Url extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
823
824
	var $name = 'Site URL';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
825
826
	protected function test() {
827
		return site_url();
828
	}
829
830
}
831
Requirements::register( 'HM\BackUpWordPress\Requirement_Site_Url', 'Site' );
832
833
class Requirement_Plugin_Version extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
834
	var $name = 'Plugin Version';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
835
836
	protected function test() {
837
		return Plugin::PLUGIN_VERSION;
838
	}
839
}
840
Requirements::register( 'HM\BackUpWordPress\Requirement_Plugin_Version', 'constants' );
841
842
class Requirement_Max_Exec extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
843
844
	var $name = 'Max execution time';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
845
846
	protected function test(){
847
		return @ini_get( 'max_execution_time' );
848
	}
849
}
850
Requirements::register( 'HM\BackUpWordPress\Requirement_Max_Exec', 'PHP' );
851
852
class Requirement_PDO extends Requirement {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
853
854
	var $name = 'PDO';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $name.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
855
856
	protected function test(){
857
858
		if ( class_exists( 'PDO' ) && \PDO::getAvailableDrivers() ) {
859
			return implode( ', ', \PDO::getAvailableDrivers() );
860
		}
861
862
		return false;
863
864
	}
865
}
866
Requirements::register( 'HM\BackUpWordPress\Requirement_PDO', 'PHP' );
867