2.12. 代理模式
目的
<?php
class RedisService {
public function get($key)
{
return 'get key '.$key;
}
}
class RedisProxy {
protected $redis;
public function __construct()
{
$this->redis = new RedisService();
}
public function __call($method, $arguments)
{
return $this->redis->{$method}(... $arguments);
}
public function gets($str) //額外功能
{
}
}
$redisProxy = new RedisProxy();
echo $redisProxy->get('user');