2012-02-24 18:22:07 +01:00
|
|
|
<?php
|
|
|
|
|
2012-08-29 16:58:03 +02:00
|
|
|
class BitrateFormatter
|
|
|
|
{
|
2012-02-24 18:22:07 +01:00
|
|
|
/**
|
|
|
|
* @string length
|
|
|
|
*/
|
|
|
|
private $_bitrate;
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// @param string $bitrate (bits per second)
|
2012-02-24 18:22:07 +01:00
|
|
|
public function __construct($bitrate)
|
|
|
|
{
|
|
|
|
$this->_bitrate = $bitrate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function format()
|
|
|
|
{
|
2012-09-18 22:40:23 +02:00
|
|
|
$kbps = bcdiv($this->_bitrate, 1000, 0);
|
2012-02-24 18:22:07 +01:00
|
|
|
|
2012-09-18 22:40:23 +02:00
|
|
|
if ($kbps == 0) {
|
2021-10-11 16:10:47 +02:00
|
|
|
return '';
|
2012-08-15 21:07:09 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return "{$kbps} Kbps";
|
2012-02-24 18:22:07 +01:00
|
|
|
}
|
2012-08-15 21:07:09 +02:00
|
|
|
}
|