Passed
Push — self-contained-model ( f0e346...f85a14 )
by Matias
04:02
created

Requirements::hasEnoughMemory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
namespace OCA\FaceRecognition\Helper;
3
4
class Requirements
5
{
6
	/**
7
	 * Determines if FaceRecognition can work with a givem image type. This is determined as
8
	 * intersection of types that are supported in Nextcloud and types that are supported in DLIB.
9
	 *
10
	 * Dlib support can be found here:
11
	 * https://github.com/davisking/dlib/blob/9b82f4b0f65a2152b4a4243c15709e5cb83f7044/dlib/image_loader/load_image.h#L21
12
	 *
13
	 * Note that Dlib supports these if it is compiled with them only! (with libjpeg, libpng...)
14
	 *
15
	 * Based on that and the fact that Nextcloud is superset of these, these are supported image types.
16
	 *
17
	 * @param string $mimeType MIME type to check if it supported
18
	 * @return true if MIME type is supported, false otherwise
19
	 */
20 4
	public static function isImageTypeSupported(string $mimeType): bool {
21
		if (
22 4
				($mimeType === 'image/jpeg') or
23 2
				($mimeType === 'image/png') or
24 2
				($mimeType === 'image/bmp') or
25 4
				($mimeType === 'image/gif')) {
26 3
			return true;
27
		} else {
28 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...
29
		}
30
	}
31
}
32