Files
huangjingfen/pro_v3.5.1/crmeb/form/components/Time.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

80 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace crmeb\form\components;
use crmeb\form\BaseComponent;
use crmeb\form\BuildInterface;
/**
* 时间组件
* Class Time
* @package crmeb\form\components
* @method Time info(string $info) 设置info
* @method Time value($value) 设置value
* @method Time type(string $type) 设置type
* @method Time placeholder(string $placeholder) 设置placeholder
*/
class Time extends BaseComponent implements BuildInterface
{
const NAME = 'time';
/**
* @var string[]
*/
protected $rule = [
'title' => '',
'value' => '',
'field' => '',
'info' => '',
'placeholder' => '',
'format' => 'HH:mm:ss',
'type' => 'timerange'
];
/**
* Time constructor.
* @param string $field
* @param string $title
* @param array|null $value
*/
public function __construct(string $field, string $title, array $value = null)
{
$this->rule['field'] = $field;
$this->rule['title'] = $title . '';
$this->rule['value'] = empty($value) ? '' : $value;
}
/**
* @return array|string[]
*/
public function toArray(): array
{
$this->rule['name'] = self::NAME;
$this->before();
return $this->rule;
}
/**
* @param $name
* @param $arguments
* @return $this
*/
public function __call($name, $arguments)
{
if (in_array($name, ['title', 'field', 'disabled', 'copyText'])) {
return $this;
}
$keys = array_keys($this->rule);
if (in_array($name, $keys)) {
$this->rule[$name] = $arguments[0] ?? null;
}
return $this;
}
}