简单的工厂类demo

2017-11-06  本文已影响0人  风的追随者

<?php
//
interface Evaluation{
public function url($params);
}
//Diggme
class Diggme implements Evaluation{

//获取跳转的url
public function url($params){
    
}

public function curl($url){

}

}
//壹心理
class Yixinli implements Evaluation{
public function url($params){
echo "yixinli的url";
}
}
//测评家
class Cepingjia implements Evaluation{
public function url($params){
echo "cepingjia的url";
}
}

class evaluationFactory{
public static function factory($Evaluation)
{

    switch ($Evaluation) {
        case 'diggme':
            return new Diggme();
            break;

        case 'yixinli':
            return new Yixinli();
            break;
        case 'Cepingjia':
            return new Cepingjia();
            break;
    }
}

}

$Evaluation=evaluationFactory::factory('diggme');
$params=[
'id'=>1
];
$Evaluation->url($params);

上一篇下一篇

猜你喜欢

热点阅读