'kuaidi100', 'holder' => [ 'kuaidi100' => [ 'driver' => KuaiDi100AdapterFactory::class, 'api_url' => 'https://poll.kuaidi100.com/poll/query.do', 'app_id' => '', 'app_key' => '' ], ], ]); $this->config = $_config; } /** * @param null $adapterName * @return Express * @throws InvalidArgumentException */ public function make($adapterName = null) { $options = $this->config; if($adapterName != null){ $this->type = $adapterName; }else{ $this->type = $options['default']; } if(!$options['holder'][$this->type]){ throw new InvalidArgumentException('lost config'); } return $this->express = Container::get($options['holder'][$this->type]['driver'])->make($options['holder'][$this->type]); } /** * 配置 * @param $config * @return $this */ public function config($config){ $this->config = $config; return $this; } /** * @return null */ public function adapter($name) { $options = $this->config; $this->type = $name; if(!$this->config['holder'][$name]){ throw new InvalidArgumentException('lost config'); } return $this->express = Container::get($options['holder'][$this->type]['driver'])->make($options['holder'][$this->type]); } /** * 查询快递 * @param $tracking_code * @param $shipping_code * @param array $additional * @return void */ public function track($tracking_code, $shipping_code, array $additional = []) { return $this->express->track($tracking_code, $shipping_code, $additional = []); } }