Base64Encode::encode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Nextcloud - Gallery
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Olivier Paroz <[email protected]>
9
 *
10
 * @copyright Olivier Paroz 2017
11
 */
12
13
namespace OCA\Gallery\Service;
14
15
/**
16
 * Base64 encoding utility method
17
 *
18
 * @package OCA\Gallery\Service
19
 */
20
trait Base64Encode {
21
22
	/**
23
	 * Returns base64 encoded data of a preview
24
	 *
25
	 * Using base64_encode for files which are downloaded
26
	 * (cached Thumbnails, SVG, GIFs) and using __toStrings
27
	 * for the previews which are instances of \OC_Image
28
	 *
29
	 * @param \OC_Image|string $previewData
30
	 *
31
	 * @return string
32
	 */
33
	protected function encode($previewData) {
34
		if ($previewData instanceof \OC_Image) {
0 ignored issues
show
Bug introduced by
The type OC_Image was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
			$previewData = (string)$previewData;
36
		} else {
37
			$previewData = base64_encode($previewData);
38
		}
39
40
		return $previewData;
41
	}
42
}
43