ipPath = config('dtapp.ip_path', ''); if (empty($this->ipPath)) { throw new DtaException('请检查配置文件是否配置了IP数据库文件存放位置'); } $this->reader = new IpIpReader($this->ipPath . 'ipipfree.ipdb'); parent::__construct($app); } /** * @param $ip * @param $language * @return array|NULL */ public function getFind(string $ip = '', string $language = 'CN') { if (empty($ip)) { $ip = get_ip(); } return $this->reader->find($ip, $language); } /** * @param $ip * @param $language * @return array|false|null */ public function getFindMap(string $ip = '', string $language = 'CN') { if (empty($ip)) { $ip = get_ip(); } return $this->reader->findMap($ip, $language); } /** * @param $ip * @param $language * @return IpIpDistrictInfo|null */ public function getFindInfo(string $ip = '', string $language = 'CN') { if (empty($ip)) { $ip = get_ip(); } $map = $this->getFindMap($ip, $language); if (NULL === $map) { return NUll; } return new IpIpDistrictInfo($map); } }