forked from printful/php-api-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintfileItem.php
More file actions
93 lines (77 loc) · 1.86 KB
/
PrintfileItem.php
File metadata and controls
93 lines (77 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace Printful\Structures\Generator;
use Printful\Structures\BaseItem;
/**
* @see https://www.printful.com/docs/generator#actionPrintfiles
* @see \Printful\PrintfulMockupGenerator::getProductPrintfiles()
*/
class PrintfileItem extends BaseItem
{
/**
* File should be fitted in the given area
*/
const FILL_MODE_FIT = 'fit';
/**
* File should cover the whole area (sublimation, posters
*/
const FILL_MODE_COVER = 'cover';
/**
* @var int
*/
public $printfileId;
/**
* Width in pixels
*
* @var int
*/
public $width;
/**
* Height in pixels
*
* @var int
*/
public $height;
/**
* Default DPI for printfile
*
* @var int
*/
public $dpi;
/**
* Default mode for image. Should it cover the area or
*
* @var string
*/
public $fillMode;
/**
* Indicates if printfile can be printed horizontal or vertical.
* This is useful for posters, canvas, where the orientation of the actual print can be changed to accommodate image orientation.
* That is, a 20x30 poster can be printed as 30x20 vertical poster if the image is vertical.
*
* @var bool
*/
public $canRotate;
/**
* @param array $raw
* @return PrintfileItem
*/
public static function fromArray(array $raw)
{
$item = new PrintfileItem;
$item->printfileId = (int)$raw['printfile_id'];
$item->width = (int)$raw['width'];
$item->height = (int)$raw['height'];
$item->dpi = (int)$raw['dpi'];
$item->fillMode = $raw['fill_mode'];
$item->canRotate = (bool)$raw['can_rotate'];
return $item;
}
/**
* Width / height ratio
* @return float
*/
public function getRatio()
{
return $this->width / $this->height;
}
}