1 | <?php |
||
25 | class DocumentLayout |
||
26 | { |
||
27 | const LAYOUT_CUSTOM = ''; |
||
28 | const LAYOUT_SCREEN_4X3 = 'screen4x3'; |
||
29 | const LAYOUT_SCREEN_16X10 = 'screen16x10'; |
||
30 | const LAYOUT_SCREEN_16X9 = 'screen16x9'; |
||
31 | const LAYOUT_35MM = '35mm'; |
||
32 | const LAYOUT_A3 = 'A3'; |
||
33 | const LAYOUT_A4 = 'A4'; |
||
34 | const LAYOUT_B4ISO = 'B4ISO'; |
||
35 | const LAYOUT_B5ISO = 'B5ISO'; |
||
36 | const LAYOUT_BANNER = 'banner'; |
||
37 | const LAYOUT_LETTER = 'letter'; |
||
38 | const LAYOUT_OVERHEAD = 'overhead'; |
||
39 | |||
40 | const UNIT_EMU = 'emu'; |
||
41 | const UNIT_CENTIMETER = 'cm'; |
||
42 | const UNIT_INCH = 'in'; |
||
43 | const UNIT_MILLIMETER = 'mm'; |
||
44 | const UNIT_PIXEL = 'px'; |
||
45 | const UNIT_POINT = 'pt'; |
||
46 | |||
47 | /** |
||
48 | * Dimension types |
||
49 | * |
||
50 | * 1 px = 9525 EMU @ 96dpi (which is seems to be the default) |
||
51 | * Absolute distances are specified in English Metric Units (EMUs), |
||
52 | * occasionally referred to as A units; there are 360000 EMUs per |
||
53 | * centimeter, 914400 EMUs per inch, 12700 EMUs per point. |
||
54 | */ |
||
55 | private $dimension = array( |
||
56 | self::LAYOUT_SCREEN_4X3 => array('cx' => 9144000, 'cy' => 6858000), |
||
57 | self::LAYOUT_SCREEN_16X10 => array('cx' => 9144000, 'cy' => 5715000), |
||
58 | self::LAYOUT_SCREEN_16X9 => array('cx' => 9144000, 'cy' => 5143500), |
||
59 | self::LAYOUT_35MM => array('cx' => 10287000, 'cy' => 6858000), |
||
60 | self::LAYOUT_A3 => array('cx' => 15120000, 'cy' => 10692000), |
||
61 | self::LAYOUT_A4 => array('cx' => 10692000, 'cy' => 7560000), |
||
62 | self::LAYOUT_B4ISO => array('cx' => 10826750, 'cy' => 8120063), |
||
63 | self::LAYOUT_B5ISO => array('cx' => 7169150, 'cy' => 5376863), |
||
64 | self::LAYOUT_BANNER => array('cx' => 7315200, 'cy' => 914400), |
||
65 | self::LAYOUT_LETTER => array('cx' => 9144000, 'cy' => 6858000), |
||
66 | self::LAYOUT_OVERHEAD => array('cx' => 9144000, 'cy' => 6858000), |
||
67 | ); |
||
68 | |||
69 | /** |
||
70 | * Layout name |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | private $layout; |
||
75 | |||
76 | /** |
||
77 | * Layout X dimension |
||
78 | * @var float |
||
79 | */ |
||
80 | private $dimensionX; |
||
81 | |||
82 | /** |
||
83 | * Layout Y dimension |
||
84 | * @var float |
||
85 | */ |
||
86 | private $dimensionY; |
||
87 | |||
88 | /** |
||
89 | * Create a new \PhpOffice\PhpPresentation\DocumentLayout |
||
90 | */ |
||
91 | 226 | public function __construct() |
|
95 | |||
96 | /** |
||
97 | * Get Document Layout |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 177 | public function getDocumentLayout() |
|
105 | |||
106 | /** |
||
107 | * Set Document Layout |
||
108 | * |
||
109 | * @param array|string $pValue |
||
110 | * @param boolean $isLandscape |
||
111 | * @return \PhpOffice\PhpPresentation\DocumentLayout |
||
112 | */ |
||
113 | 226 | public function setDocumentLayout($pValue = self::LAYOUT_SCREEN_4X3, $isLandscape = true) |
|
147 | |||
148 | /** |
||
149 | * Get Document Layout cx |
||
150 | * |
||
151 | * @param string $unit |
||
152 | * @return integer |
||
153 | */ |
||
154 | 178 | public function getCX($unit = self::UNIT_EMU) |
|
158 | |||
159 | /** |
||
160 | * Get Document Layout cy |
||
161 | * |
||
162 | * @param string $unit |
||
163 | * @return integer |
||
164 | */ |
||
165 | 178 | public function getCY($unit = self::UNIT_EMU) |
|
169 | |||
170 | /** |
||
171 | * Get Document Layout cx |
||
172 | * |
||
173 | * @param float $value |
||
174 | * @param string $unit |
||
175 | * @return DocumentLayout |
||
176 | */ |
||
177 | 1 | public function setCX($value, $unit = self::UNIT_EMU) |
|
183 | |||
184 | /** |
||
185 | * Get Document Layout cy |
||
186 | * |
||
187 | * @param float $value |
||
188 | * @param string $unit |
||
189 | * @return DocumentLayout |
||
190 | */ |
||
191 | 1 | public function setCY($value, $unit = self::UNIT_EMU) |
|
197 | |||
198 | /** |
||
199 | * Convert EMUs to differents units |
||
200 | * @param float $value |
||
201 | * @param string $fromUnit |
||
202 | * @param string $toUnit |
||
203 | * @return float |
||
204 | */ |
||
205 | 179 | protected function convertUnit($value, $fromUnit, $toUnit) |
|
252 | } |
||
253 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.