<?php

namespace Application\Service\Extension\Formatter;


class BaseFormatter
{

    public array $handlerMap = [
        'create_time' => 'createTimeHandler',
        'update_time' => 'updateTimeHandler',
        'create_user_id' => 'createByHandler',
    ];

    public function registerHandler(array $handler)
    {
        $this->handlerMap = array_merge($handler, $this->handlerMap);
    }

    public function createTimeHandler($value, $item)
    {
        return date('Y-m-d H:i:s', $value);
    }


    public function updateTimeHandler($value)
    {
        return date('Y-m-d H:i:s', $value);
    }

    public function createByHandler($value)
    {
        return $value;
    }
}