Repository navigation
Expand file tree
/
Copy pathBaseDriver.php
More file actions
160 lines (139 loc) · 2.89 KB
/
Copy pathBaseDriver.php
File metadata and controls
160 lines (139 loc) · 2.89 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
namespace AsyncPHP\Paper\Driver;
use AsyncPHP\Paper\Driver;
abstract class BaseDriver implements Driver
{
use Traits\AppendsTrait;
use Traits\AppendsHeaderTrait;
use Traits\AppendsFooterTrait;
/**
* @var string
*/
protected $header;
/**
* @var string
*/
protected $body;
/**
* @var string
*/
protected $footer;
/**
* @var string
*/
protected $size = "A4";
/**
* @var string
*/
protected $orientation = "portrait";
/**
* @var int
*/
protected $dpi = 300;
/**
* @inheritdoc
*
* @param null|string $header
*
* @return string|static
*/
public function header($header = null)
{
return $this->access("header", $header);
}
/**
* Works as a universal getter and setter.
*
* @param string $key
* @param mixed $value
*/
private function access($key, $value = null)
{
if (is_null($value)) {
return $this->$key;
}
$this->$key = $value;
return $this;
}
/**
* @inheritdoc
*
* @param null|string $body
*
* @return string|static
*/
public function body($body = null)
{
return $this->access("body", $body);
}
/**
* @inheritdoc
*
* @param null|string $footer
*
* @return string|static
*/
public function footer($footer = null)
{
return $this->access("footer", $footer);
}
/**
* @inheritdoc
*
* @param null|string $size
*
* @return string|static
*/
public function size($size = null)
{
return $this->access("size", $size);
}
/**
* @inheritdoc
*
* @param null|string $orientation
*
* @return string|static
*/
public function orientation($orientation = null)
{
return $this->access("orientation", $orientation);
}
/**
* @inheritdoc
*
* @param null|int $dpi
*
* @return int|static
*/
public function dpi($dpi = null)
{
return $this->access("dpi", $dpi);
}
/**
* Get context variables for parallel execution.
*
* @return array
*/
protected function data()
{
$html = $this->appends(
$this->body, "head", "<style>html,body{height:100%;position:relative;}</style>"
);
if ($this->header) {
$html = $this->appendsHeader($html, $this->header);
}
if ($this->footer) {
$html = $this->appendsFooter($html, $this->footer);
}
return [
"header" => $this->header,
"body" => $this->body,
"footer" => $this->footer,
"html" => $html,
"size" => $this->size,
"orientation" => $this->orientation,
"dpi" => $this->dpi,
];
}
}