[TASK] Replace sprite icon "actions-view-table-*" with the new IconFactory
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Imaging / Dimension.php
1 <?php
2 namespace TYPO3\CMS\Core\Imaging;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Dimension class holds width and height for an icon
19 */
20 class Dimension {
21
22 /**
23 * @var int
24 */
25 protected $width;
26
27 /**
28 * @var int
29 */
30 protected $height;
31
32 /**
33 * Constructor which fetches the size and resolves it to a pixel size
34 *
35 * @param string $size the icon size
36 *
37 * @throws \InvalidArgumentException
38 */
39 public function __construct($size = Icon::SIZE_DEFAULT) {
40 switch ($size) {
41 case Icon::SIZE_LARGE:
42 $sizeInPixel = 48;
43 break;
44 case Icon::SIZE_DEFAULT:
45 $sizeInPixel = 32;
46 break;
47 case Icon::SIZE_SMALL:
48 case Icon::SIZE_OVERLAY:
49 $sizeInPixel = 16;
50 break;
51 default:
52 throw new \InvalidArgumentException('The given size ' . $size . ' is not a valid size, see Icon class for options', 1438871603);
53 }
54
55 $this->width = (int)$sizeInPixel;
56 $this->height = (int)$sizeInPixel;
57 }
58
59 /**
60 * Returns the width
61 * @return int
62 */
63 public function getWidth() {
64 return $this->width;
65 }
66
67 /**
68 * Returns the height
69 * @return int
70 */
71 public function getHeight() {
72 return $this->height;
73 }
74 }