<?php


namespace common\libs\dataList\column;
use common\helpers\Config as ConfigHelper;

class Area extends AbstractColumn implements InterfaceColumn {

    public function __construct($config = []) {
        parent::__construct($config);
    }
    public function format(){
        $value = $this->getValue();
        if(!$value){
            return null;
        }
        $count = count($value);
        switch ($count){
            case 1:
                $data = ConfigHelper::province($value[0]);
                break;
            case 2:
                $data = ConfigHelper::city($value[0], $value[1]);
                break;
            case 3:
                $data = ConfigHelper::county($value[0], $value[1], $value[2]);
                break;
            default:
                $data = null;
                break;
        }
        return ($data && isset($data['REGION_NAME'])) ? $data['REGION_NAME'] : $this->defaultText;
    }
    public function result(){
        return $this->format();
    }
}