<?php
/**
 * Created by PhpStorm.
 * User: sunmoon<i@liming.me>
 * Date: 2019/07/29
 * Time: 上午9:39
 */


namespace common\libs\logging\operate\valueType;

use yii\base\Component;

abstract class AbstractValueType extends Component {
    /**
     * @var
     */
    public $data = [];
    /**
     * @var null
     */
    public $mapLabel = null;
    /**
     * @var
     */
    public $value;
    /**
     * @var string
     */
    public $defaultText = '';
    /**
     * AbstractValueType constructor.
     * @param array $config
     */
    public function __construct($config = []) {
        parent::__construct($config);
    }
    public function setValue($value){
        $this->value = $value;
    }
    public function getValue(){
        return $this->value;
    }

    /**
     * 处理传入的值
     */
    public function handleValue(){
        $value = $this->getValue();
        if(!is_array($value)){
            if(strpos($value, ',') !== false){
                $value = explode(',', $value);
            }else{
                $value = (array)$value;
            }
        }
        $this->value = $value;
    }
}