Passed
Pull Request — master (#232)
by Matias
05:40 queued 04:10
created

Requirements::getModel1File()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 5
cp 0.8
crap 2.032
rs 10
1
<?php
2
namespace OCA\FaceRecognition\Helper;
3
4
use OCA\FaceRecognition\Helper\MemoryLimits;
5
6
use OCA\FaceRecognition\Service\SettingsService;
7
8
class Requirements
9
{
10
	public static function hasEnoughMemory() {
11
		$memory = MemoryLimits::getSystemMemory();
12
		return ($memory > SettingsService::MINIMUM_SYSTEM_MEMORY_REQUIREMENTS);
13
	}
14
15
	public static function pdlibLoaded() {
16
		return extension_loaded('pdlib');
17
	}
18
19
	/**
20
	 * Determines if FaceRecognition can work with a givem image type. This is determined as
21
	 * intersection of types that are supported in Nextcloud and types that are supported in DLIB.
22
	 *
23
	 * Dlib support can be found here:
24
	 * https://github.com/davisking/dlib/blob/9b82f4b0f65a2152b4a4243c15709e5cb83f7044/dlib/image_loader/load_image.h#L21
25
	 *
26
	 * Note that Dlib supports these if it is compiled with them only! (with libjpeg, libpng...)
27
	 *
28
	 * Based on that and the fact that Nextcloud is superset of these, these are supported image types.
29
	 *
30
	 * @param string $mimeType MIME type to check if it supported
31
	 * @return true if MIME type is supported, false otherwise
32
	 */
33 8
	public static function isImageTypeSupported(string $mimeType): bool {
34
		if (
35 8
				($mimeType === 'image/jpeg') or
36 2
				($mimeType === 'image/png') or
37 2
				($mimeType === 'image/bmp') or
38 8
				($mimeType === 'image/gif')) {
39 7
			return true;
40
		} else {
41 2
			return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type true.
Loading history...
42
		}
43
	}
44
}
45