@@ -86,29 +86,36 @@ public function __construct(string $path, bool $checkFile = false)
8686 * the file in the $_FILES array if available, as PHP calculates this based
8787 * on the actual size transmitted.
8888 *
89- * @param string $unit The unit to return:
90- * - b Bytes
91- * - kb Kilobytes
92- * - mb Megabytes
93- *
94- * @return integer|null The file size in bytes or null if unknown.
89+ * @return integer The file size in bytes
9590 */
96- public function getSize (string $ unit = ' b ' )
91+ public function getSize ()
9792 {
9893 if (is_null ($ this ->size ))
9994 {
100- $ this ->size = filesize ( $ this -> getPathname () );
95+ $ this ->size = parent :: getSize ( );
10196 }
10297
98+ return $ this ->size ;
99+ }
100+
101+ /**
102+ * Retrieve the file size by unit.
103+ *
104+ * @param string $unit
105+ *
106+ * @return integer|string
107+ */
108+ public function getSizeByUnit (string $ unit = 'b ' )
109+ {
103110 switch (strtolower ($ unit ))
104111 {
105112 case 'kb ' :
106- return number_format ($ this ->size / 1024 , 3 );
113+ return number_format ($ this ->getSize () / 1024 , 3 );
107114 case 'mb ' :
108- return number_format (($ this ->size / 1024 ) / 1024 , 3 );
115+ return number_format (($ this ->getSize () / 1024 ) / 1024 , 3 );
116+ default :
117+ return $ this ->getSize ();
109118 }
110-
111- return (int ) $ this ->size ;
112119 }
113120
114121 //--------------------------------------------------------------------
0 commit comments