for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Arbor\Moment\Formatter;
use Arbor\Moment\Time;
/**
* Class TimeFormatter
*
* @package Arbor\Moment\Formatter
* @author Igor Vuckovic <[email protected]>
*/
class TimeFormatter implements FormatterInterface
{
/** @var Time */
private $time;
* @param Time $time
public function __construct(Time $time)
$this->time = $time;
}
* {@inheritdoc}
public function getShort() : string
$hours = (string)$this->time->getHours();
$minutes = (string)$this->time->getMinutes();
return str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($minutes, 2, '0', STR_PAD_LEFT);
public function getLong() : string
$seconds = (string)$this->time->getSeconds();
return $this->getShort() . ':' . str_pad($seconds, 2, '0', STR_PAD_LEFT);