| @@ 147-156 (lines=10) @@ | ||
| 144 | * |
|
| 145 | * @return Filesize |
|
| 146 | */ |
|
| 147 | public static function fromMegaBytes($megabytes) |
|
| 148 | { |
|
| 149 | if (!is_int($megabytes) && !is_float($megabytes)) { |
|
| 150 | throw new InvalidArgumentException('Given amount must be an integer or a float'); |
|
| 151 | } |
|
| 152 | ||
| 153 | $bytes = $megabytes * pow(1024, 2); |
|
| 154 | ||
| 155 | return new self((int) round($bytes, 0)); |
|
| 156 | } |
|
| 157 | ||
| 158 | /** |
|
| 159 | * Creates instance from a kilobyte string notation |
|
| @@ 203-212 (lines=10) @@ | ||
| 200 | * |
|
| 201 | * @return Filesize |
|
| 202 | */ |
|
| 203 | public static function fromKiloBytes($kilobytes) |
|
| 204 | { |
|
| 205 | if (!is_int($kilobytes) && !is_float($kilobytes)) { |
|
| 206 | throw new InvalidArgumentException('Given amount must be an integer or a float'); |
|
| 207 | } |
|
| 208 | ||
| 209 | $bytes = $kilobytes * 1024; |
|
| 210 | ||
| 211 | return new self((int) round($bytes, 0)); |
|
| 212 | } |
|
| 213 | ||
| 214 | /** |
|
| 215 | * Creates a new instance from given Filesize object |
|