Channel.php 897 Bytes
<?php

namespace WebPlugin\DataProcess;

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'
    );

    public static function getFormat($channel, $data)
    {
        if (empty($data)) {
            return array();
        }
        // 通用处理器
        $result = Process::getContent($data, $channel);
        $channelResult = array();
        if (isset(self::$formatChannel[$channel])) {
            $class = self::$formatChannel[$channel];
            $channelResult = $class::format($data);
        }
        // 组合数据
        $result = $result + $channelResult;
        ksort($result);
        return array_values($result);
    }

}