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\DateTime;
/**
* Class DateTimeFormatter
*
* @package Arbor\Moment\Formatter
* @author Igor Vuckovic <[email protected]>
*/
class DateTimeFormatter implements FormatterInterface
{
/** @var DateTime */
private $dateTime;
* @param DateTime $dateTime
public function __construct(DateTime $dateTime)
$this->dateTime = $dateTime;
}
* {@inheritdoc}
public function getShort() : string
return $this->dateTime->format(DateTime::FORMAT_SHORT);
public function getLong() : string
$format = DateTime::FORMAT_SHORT;
if ($this->dateTime->getDateType() === DateTime::TYPE_DATETIME) {
$format .= ', ' . DateTime::FORMAT_TIME;
return $this->dateTime->format($format);