| Total Complexity | 4 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class GeocodeCollectionComponent extends Component implements Collection |
||
| 11 | { |
||
| 12 | public $apikey; |
||
| 13 | |||
| 14 | public $useProxy = false; |
||
| 15 | |||
| 16 | public $proxyConf = [ |
||
| 17 | 'url' => '127.0.0.1', |
||
| 18 | 'port' => '3128', |
||
| 19 | 'login' => null, |
||
| 20 | 'password' => null |
||
| 21 | ]; |
||
| 22 | |||
| 23 | private $geocode; |
||
| 24 | |||
| 25 | /** @var Collection */ |
||
| 26 | private $collection; |
||
| 27 | |||
| 28 | public function init() |
||
| 29 | { |
||
| 30 | parent::init(); |
||
| 31 | |||
| 32 | if(\Yii::$container->has(\talismanfr\geocode\contracts\Geocode::class)){ |
||
| 33 | $this->geocode=\Yii::$container->get(\talismanfr\geocode\contracts\Geocode::class); |
||
| 34 | }else{ |
||
| 35 | $geocode=new Geocode(); |
||
| 36 | $geocode->apikey=$this->apikey; |
||
| 37 | $geocode->useProxy=$this->useProxy; |
||
| 38 | $geocode->proxyConf=$this->proxyConf; |
||
| 39 | $this->geocode=$geocode; |
||
| 40 | } |
||
| 41 | |||
| 42 | $this->collection=new GeocodeCollection($this->geocode); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function get($query): array |
||
| 46 | { |
||
| 47 | return $this->collection->get($query); |
||
| 48 | } |
||
| 49 | |||
| 50 | public function one($query) |
||
| 53 | } |
||
| 54 | } |