Completed
Push — stable9 ( ab68a4...eef0b3 )
by Olivier
10s
created

ThumbnailService::getThumbnailSpecs()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 * ownCloud - galleryplus
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 2014-2016
11
 */
12
13
namespace OCA\GalleryPlus\Service;
14
15
/**
16
 * Deals with any thumbnail specific requests
17
 *
18
 * @package OCA\GalleryPlus\Service
19
 */
20
class ThumbnailService {
21
22
	/**
23
	 * @var bool
24
	 */
25
	private $animatedPreview = false;
26
	/**
27
	 * @var bool
28
	 */
29
	private $base64Encode = true;
30
31
	/**
32
	 * Returns thumbnail specs
33
	 *
34
	 *    * Album thumbnails need to be 200x200 and some will be resized by the
35
	 *      browser to 200x100 or 100x100.
36
	 *    * Standard thumbnails are 400x200.
37
	 *
38
	 * @param bool $square
39
	 * @param double $scale
40
	 *
41
	 * @return array<double|boolean>
42
	 */
43 5
	public function getThumbnailSpecs($square, $scale) {
44 5
		$height = ceil(200 * $scale);
45 5
		if ($square) {
46 2
			$width = $height;
47
		} else {
48 3
			$width = 2 * $height;
49
		}
50
51 5
		$thumbnail = [$width, $height, !$square, $this->animatedPreview, $this->base64Encode];
52
53 5
		return $thumbnail;
54
	}
55
56
}
57