1717
1818namespace PhpOffice \Common ;
1919
20- /**
21- * \PhpOffice\Common\Drawing
22- */
2320class Drawing
2421{
2522 public const DPI_96 = 96 ;
@@ -29,9 +26,9 @@ class Drawing
2926 *
3027 * @param int $pValue Value in pixels
3128 *
32- * @return int
29+ * @return float
3330 */
34- public static function pixelsToEmu ($ pValue = 0 )
31+ public static function pixelsToEmu (int $ pValue = 0 ): float
3532 {
3633 return round ($ pValue * 9525 );
3734 }
@@ -41,9 +38,9 @@ public static function pixelsToEmu($pValue = 0)
4138 *
4239 * @param int $pValue Value in EMU
4340 *
44- * @return int
41+ * @return float
4542 */
46- public static function emuToPixels ($ pValue = 0 )
43+ public static function emuToPixels (int $ pValue = 0 ): float
4744 {
4845 if ($ pValue == 0 ) {
4946 return 0 ;
@@ -59,7 +56,7 @@ public static function emuToPixels($pValue = 0)
5956 *
6057 * @return float
6158 */
62- public static function pixelsToPoints ($ pValue = 0 )
59+ public static function pixelsToPoints (int $ pValue = 0 ): float
6360 {
6461 return $ pValue * 0.67777777 ;
6562 }
@@ -71,7 +68,7 @@ public static function pixelsToPoints($pValue = 0)
7168 *
7269 * @return float
7370 */
74- public static function pointsToCentimeters ($ pValue = 0 )
71+ public static function pointsToCentimeters (int $ pValue = 0 ): float
7572 {
7673 if ($ pValue == 0 ) {
7774 return 0 ;
@@ -87,7 +84,7 @@ public static function pointsToCentimeters($pValue = 0)
8784 *
8885 * @return float
8986 */
90- public static function pointsToPixels ($ pValue = 0 )
87+ public static function pointsToPixels (int $ pValue = 0 ): float
9188 {
9289 if ($ pValue == 0 ) {
9390 return 0 ;
@@ -103,7 +100,7 @@ public static function pointsToPixels($pValue = 0)
103100 *
104101 * @return float
105102 */
106- public static function pixelsToCentimeters ($ pValue = 0 )
103+ public static function pixelsToCentimeters (int $ pValue = 0 ): float
107104 {
108105 //return $pValue * 0.028;
109106 return ($ pValue / self ::DPI_96 ) * 2.54 ;
@@ -116,7 +113,7 @@ public static function pixelsToCentimeters($pValue = 0)
116113 *
117114 * @return float
118115 */
119- public static function centimetersToPixels ($ pValue = 0 )
116+ public static function centimetersToPixels (int $ pValue = 0 ): float
120117 {
121118 if ($ pValue == 0 ) {
122119 return 0 ;
@@ -132,7 +129,7 @@ public static function centimetersToPixels($pValue = 0)
132129 *
133130 * @return int
134131 */
135- public static function degreesToAngle ($ pValue = 0 )
132+ public static function degreesToAngle (int $ pValue = 0 ): int
136133 {
137134 return (int ) round ($ pValue * 60000 );
138135 }
@@ -142,9 +139,9 @@ public static function degreesToAngle($pValue = 0)
142139 *
143140 * @param int $pValue Angle
144141 *
145- * @return int
142+ * @return float
146143 */
147- public static function angleToDegrees ($ pValue = 0 )
144+ public static function angleToDegrees (int $ pValue = 0 ): float
148145 {
149146 if ($ pValue == 0 ) {
150147 return 0 ;
@@ -160,7 +157,7 @@ public static function angleToDegrees($pValue = 0)
160157 *
161158 * @return float
162159 */
163- public static function centimetersToTwips ($ pValue = 0 )
160+ public static function centimetersToTwips (int $ pValue = 0 ): float
164161 {
165162 if ($ pValue == 0 ) {
166163 return 0 ;
@@ -176,7 +173,7 @@ public static function centimetersToTwips($pValue = 0)
176173 *
177174 * @return float
178175 */
179- public static function twipsToCentimeters ($ pValue = 0 )
176+ public static function twipsToCentimeters (int $ pValue = 0 ): float
180177 {
181178 if ($ pValue == 0 ) {
182179 return 0 ;
@@ -190,9 +187,9 @@ public static function twipsToCentimeters($pValue = 0)
190187 *
191188 * @param int $pValue
192189 *
193- * @return float
190+ * @return int
194191 */
195- public static function inchesToTwips ($ pValue = 0 )
192+ public static function inchesToTwips (int $ pValue = 0 ): int
196193 {
197194 if ($ pValue == 0 ) {
198195 return 0 ;
@@ -208,7 +205,7 @@ public static function inchesToTwips($pValue = 0)
208205 *
209206 * @return float
210207 */
211- public static function twipsToInches ($ pValue = 0 )
208+ public static function twipsToInches (int $ pValue = 0 ): float
212209 {
213210 if ($ pValue == 0 ) {
214211 return 0 ;
@@ -224,7 +221,7 @@ public static function twipsToInches($pValue = 0)
224221 *
225222 * @return float
226223 */
227- public static function twipsToPixels ($ pValue = 0 )
224+ public static function twipsToPixels (int $ pValue = 0 ): float
228225 {
229226 if ($ pValue == 0 ) {
230227 return 0 ;
@@ -238,9 +235,9 @@ public static function twipsToPixels($pValue = 0)
238235 *
239236 * @param string $pValue HTML Color in hexadecimal
240237 *
241- * @return array|false Value in RGB
238+ * @return array<int, int>|null Value in RGB
242239 */
243- public static function htmlToRGB ($ pValue )
240+ public static function htmlToRGB (string $ pValue ): ? array
244241 {
245242 if ($ pValue [0 ] == '# ' ) {
246243 $ pValue = substr ($ pValue , 1 );
@@ -251,7 +248,7 @@ public static function htmlToRGB($pValue)
251248 } elseif (strlen ($ pValue ) == 3 ) {
252249 list ($ colorR , $ colorG , $ colorB ) = [$ pValue [0 ] . $ pValue [0 ], $ pValue [1 ] . $ pValue [1 ], $ pValue [2 ] . $ pValue [2 ]];
253250 } else {
254- return false ;
251+ return null ;
255252 }
256253
257254 $ colorR = hexdec ($ colorR );
0 commit comments