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

ThumbnailService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 37
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getThumbnailSpecs() 0 12 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