|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Sprain\SwissQrBill\PaymentPart\Output\Element; |
|
4
|
|
|
|
|
5
|
|
|
class Placeholder implements OutputElementInterface |
|
6
|
|
|
{ |
|
7
|
|
|
public const FILE_TYPE_SVG = 'svg'; |
|
8
|
|
|
public const FILE_TYPE_PNG = 'png'; |
|
9
|
|
|
|
|
10
|
|
|
public const PLACEHOLDER_TYPE_PAYABLE_BY = [ |
|
11
|
|
|
'type' => 'placeholder_payable_by', |
|
12
|
|
|
'fileSvg' => __DIR__ . '/../../../../assets/marks_65x25mm.svg', |
|
13
|
|
|
'filePng' => __DIR__ . '/../../../../assets/marks_65x25mm.png', |
|
14
|
|
|
'width' => 65, |
|
15
|
|
|
'height' => 25, |
|
16
|
|
|
'float' => 'left', |
|
17
|
|
|
'marginTop' => 0, // In mm. |
|
18
|
|
|
]; |
|
19
|
|
|
|
|
20
|
|
|
public const PLACEHOLDER_TYPE_PAYABLE_BY_RECEIPT = [ |
|
21
|
|
|
'type' => 'placeholder_payable_by_receipt', |
|
22
|
|
|
'fileSvg' => __DIR__ . '/../../../../assets/marks_52x20mm.svg', |
|
23
|
|
|
'filePng' => __DIR__ . '/../../../../assets/marks_52x20mm.png', |
|
24
|
|
|
'width' => 52, |
|
25
|
|
|
'height' => 20, |
|
26
|
|
|
'float' => 'right', |
|
27
|
|
|
'marginTop' => 0, // In mm. |
|
28
|
|
|
]; |
|
29
|
|
|
|
|
30
|
|
|
public const PLACEHOLDER_TYPE_AMOUNT = [ |
|
31
|
|
|
'type' => 'placeholder_amount', |
|
32
|
|
|
'fileSvg' => __DIR__ . '/../../../../assets/marks_40x15mm.svg', |
|
33
|
|
|
'filePng' => __DIR__ . '/../../../../assets/marks_40x15mm.png', |
|
34
|
|
|
'width' => 40, |
|
35
|
|
|
'height' => 15, |
|
36
|
|
|
'float' => 'right', |
|
37
|
|
|
'marginTop' => -0.9 // In mm. |
|
38
|
|
|
]; |
|
39
|
|
|
|
|
40
|
|
|
public const PLACEHOLDER_TYPE_AMOUNT_RECEIPT = [ |
|
41
|
|
|
'type' => 'placeholder_amount_receipt', |
|
42
|
|
|
'fileSvg' => __DIR__ . '/../../../../assets/marks_30x10mm.svg', |
|
43
|
|
|
'filePng' => __DIR__ . '/../../../../assets/marks_30x10mm.png', |
|
44
|
|
|
'width' => 30, |
|
45
|
|
|
'height' => 10, |
|
46
|
|
|
'float' => 'right', |
|
47
|
|
|
'marginTop' => -3.175 // In mm. |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
|
|
/** @var string */ |
|
51
|
|
|
private $type; |
|
52
|
|
|
|
|
53
|
|
|
/** @var string */ |
|
54
|
|
|
private $fileSvg; |
|
55
|
|
|
|
|
56
|
|
|
/** @var string */ |
|
57
|
|
|
private $filePng; |
|
58
|
|
|
|
|
59
|
|
|
/** @var int */ |
|
60
|
|
|
private $width; |
|
61
|
|
|
|
|
62
|
|
|
/** @var int */ |
|
63
|
|
|
private $height; |
|
64
|
|
|
|
|
65
|
|
|
/** @var string */ |
|
66
|
|
|
private $float; |
|
67
|
|
|
|
|
68
|
|
|
/** @var int */ |
|
69
|
|
|
private $marginTop; |
|
70
|
|
|
|
|
71
|
|
|
public static function create(array $type): self |
|
72
|
|
|
{ |
|
73
|
|
|
$placeholder = new self(); |
|
74
|
|
|
$placeholder->type = $type['type']; |
|
75
|
|
|
$placeholder->fileSvg = $type['fileSvg']; |
|
76
|
|
|
$placeholder->filePng = $type['filePng']; |
|
77
|
|
|
$placeholder->width = $type['width']; |
|
78
|
|
|
$placeholder->height = $type['height']; |
|
79
|
|
|
$placeholder->float = $type['float']; |
|
80
|
|
|
$placeholder->marginTop = $type['marginTop']; |
|
81
|
|
|
|
|
82
|
|
|
return $placeholder; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function getType(): ?string |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->type; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function getFile($type = self::FILE_TYPE_SVG): string |
|
91
|
|
|
{ |
|
92
|
|
|
switch ($type) { |
|
93
|
|
|
case self::FILE_TYPE_PNG: |
|
94
|
|
|
return $this->filePng; |
|
95
|
|
|
case self::FILE_TYPE_SVG: |
|
96
|
|
|
default: |
|
97
|
|
|
return $this->fileSvg; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function getWidth(): ?int |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->width; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function getHeight(): ?int |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->height; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
public function getFloat(): ?string |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->float; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function getMarginTop(): float |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->marginTop ?: 0; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|