@@ -93,30 +93,7 @@ protected function formatColor(array $values):string{
93
93
}
94
94
95
95
public function dump (string |null $ file = null ):string {
96
- [$ width , $ height ] = $ this ->getOutputDimensions ();
97
-
98
- $ eps = [
99
- // main header
100
- '%!PS-Adobe-3.0 EPSF-3.0 ' ,
101
- '%%Creator: php-qrcode (https://github.com/chillerlan/php-qrcode) ' ,
102
- '%%Title: QR Code ' ,
103
- sprintf ('%%%%CreationDate: %1$s ' , date ('c ' )),
104
- '%%DocumentData: Clean7Bit ' ,
105
- '%%LanguageLevel: 3 ' ,
106
- sprintf ('%%%%BoundingBox: 0 0 %s %s ' , $ width , $ height ),
107
- '%%EndComments ' ,
108
- // function definitions
109
- '%%BeginProlog ' ,
110
- '/F { rectfill } def ' ,
111
- '/R { setrgbcolor } def ' ,
112
- '/C { setcmykcolor } def ' ,
113
- '%%EndProlog ' ,
114
- ];
115
-
116
- if ($ this ::moduleValueIsValid ($ this ->options ->bgColor )){
117
- $ eps [] = $ this ->prepareModuleValue ($ this ->options ->bgColor );
118
- $ eps [] = sprintf ('0 0 %s %s F ' , $ width , $ height );
119
- }
96
+ $ eps = $ this ->header ();
120
97
121
98
// create the path elements
122
99
$ paths = $ this ->collectModules ($ this ->module (...));
@@ -141,6 +118,40 @@ public function dump(string|null $file = null):string{
141
118
return $ data ;
142
119
}
143
120
121
+ /**
122
+ * Returns the main header for the EPS file, including function definitions and background
123
+ *
124
+ * @return array<int, string>
125
+ */
126
+ protected function header ():array {
127
+ [$ width , $ height ] = $ this ->getOutputDimensions ();
128
+
129
+ $ header = [
130
+ // main header
131
+ '%!PS-Adobe-3.0 EPSF-3.0 ' ,
132
+ '%%Creator: php-qrcode (https://github.com/chillerlan/php-qrcode) ' ,
133
+ '%%Title: QR Code ' ,
134
+ sprintf ('%%%%CreationDate: %1$s ' , date ('c ' )),
135
+ '%%DocumentData: Clean7Bit ' ,
136
+ '%%LanguageLevel: 3 ' ,
137
+ sprintf ('%%%%BoundingBox: 0 0 %s %s ' , $ width , $ height ),
138
+ '%%EndComments ' ,
139
+ // function definitions
140
+ '%%BeginProlog ' ,
141
+ '/F { rectfill } def ' ,
142
+ '/R { setrgbcolor } def ' ,
143
+ '/C { setcmykcolor } def ' ,
144
+ '%%EndProlog ' ,
145
+ ];
146
+
147
+ if ($ this ::moduleValueIsValid ($ this ->options ->bgColor )){
148
+ $ header [] = $ this ->prepareModuleValue ($ this ->options ->bgColor );
149
+ $ header [] = sprintf ('0 0 %s %s F ' , $ width , $ height );
150
+ }
151
+
152
+ return $ header ;
153
+ }
154
+
144
155
/**
145
156
* Returns a path segment for a single module
146
157
*/
0 commit comments