Channel.php 1.15 KB
<?php

namespace WebPlugin\DataProcess;

use WebPlugin\Helpers;
class Channel
{

    public static $formatChannel = array(
        'boys' => '\WebPlugin\DataProcess\Channel\Boys',
        'girls' => '\WebPlugin\DataProcess\Channel\Girls',
        'kids' => '\WebPlugin\DataProcess\Channel\Kids',
        'lifestyle' => '\WebPlugin\DataProcess\Channel\Lifestyle',
        'plusstarIndex' => '\WebPlugin\DataProcess\Channel\PlusstarIndex'
    );
    
    /**
     * 获取格式数据
     * 
     * @param string $channel
     * @param array $data
     */
    public static function getFormat($channel, array $data)
    {
        if (empty($data)) {
            return array();
        }
        // 通用处理器
        $result = Process::getContent($data, Helpers::getChannelNameByCookie());
        $channelResult = array();
        if (isset(self::$formatChannel[$channel])) {
            $class = self::$formatChannel[$channel];
            $channelResult = $class::format($data);
        }
        // 组合数据
        $result = $result + $channelResult;
        ksort($result);
        return array_values($result);
    }

}