1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the php-phantomjs. |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace JonnyW\PhantomJs\Page; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* PHP PhantomJs. |
14
|
|
|
* |
15
|
|
|
* @author Jon Wenmoth <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class PaperSize implements \JsonSerializable |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Width. |
21
|
|
|
* |
22
|
|
|
* @var int |
23
|
|
|
*/ |
24
|
|
|
private $width; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Height. |
28
|
|
|
* |
29
|
|
|
* @var int |
30
|
|
|
*/ |
31
|
|
|
private $height; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Margin. |
35
|
|
|
* |
36
|
|
|
* @var int|JonnyW\PhantomJs\Page\Margin |
37
|
|
|
*/ |
38
|
|
|
protected $margin; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Header. |
42
|
|
|
* |
43
|
|
|
* @var \JonnyW\PhantomJs\Page\PaperBlock |
44
|
|
|
*/ |
45
|
|
|
protected $header; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Footer. |
49
|
|
|
* |
50
|
|
|
* @var \JonnyW\PhantomJs\Page\PaperBlock |
51
|
|
|
*/ |
52
|
|
|
protected $footer; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Internal constructor. |
56
|
|
|
* |
57
|
|
|
* @param int $width |
58
|
|
|
* @param int $height |
59
|
|
|
* @param int|JonnyW\PhantomJs\Page\Margin $margin (default: 0) |
60
|
|
|
*/ |
61
|
|
|
public function __construct($width, $height, $margin = 0) |
62
|
|
|
{ |
63
|
|
|
$this->width = (int) $width; |
64
|
|
|
$this->height = (int) $height; |
65
|
|
|
$this->margin = $margin; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Set header. |
70
|
|
|
* |
71
|
|
|
* @param \JonnyW\PhantomJs\Page\PaperBlock $header |
72
|
|
|
* |
73
|
|
|
* @return |JonnyW\PhantomJs\Page\PaperSize |
|
|
|
|
74
|
|
|
*/ |
75
|
|
|
public function setHeader(PaperBlock $header) |
76
|
|
|
{ |
77
|
|
|
$this->header = $header; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Set footer. |
84
|
|
|
* |
85
|
|
|
* @param \JonnyW\PhantomJs\Page\PaperBlock $footer |
86
|
|
|
* |
87
|
|
|
* @return |JonnyW\PhantomJs\Page\PaperSize |
|
|
|
|
88
|
|
|
*/ |
89
|
|
|
public function setFooter(PaperBlock $footer) |
90
|
|
|
{ |
91
|
|
|
$this->footer = $footer; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Format data for JSON serialization. |
98
|
|
|
* |
99
|
|
|
* @return array |
100
|
|
|
*/ |
101
|
|
|
public function jsonSerialize() |
102
|
|
|
{ |
103
|
|
|
return array_filter(array( |
104
|
|
|
'width' => $this->width, |
105
|
|
|
'height' => $this->height, |
106
|
|
|
'margin' => $this->margin, |
107
|
|
|
'header' => $this.header, |
108
|
|
|
'footer' => $this->footer, |
109
|
|
|
)); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.