File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 11<?php
2+
23namespace Torann \GeoIP \Services ;
4+
35use Exception ;
46use Illuminate \Support \Arr ;
57use Torann \GeoIP \Support \HttpClient ;
8+
69/**
710 * Class GeoIP
811 * @package Torann\GeoIP\Services
@@ -15,6 +18,7 @@ class IPFinder extends AbstractService
1518 * @var HttpClient
1619 */
1720 protected $ client ;
21+
1822 /**
1923 * The "booting" method of the service.
2024 *
@@ -32,6 +36,7 @@ public function boot()
3236 ],
3337 ]);
3438 }
39+
3540 /**
3641 * {@inheritdoc}
3742 * @throws Exception
@@ -40,11 +45,14 @@ public function locate($ip)
4045 {
4146 // Get data from client
4247 $ data = $ this ->client ->get ($ ip );
48+
4349 // Verify server response
4450 if ($ this ->client ->getErrors () !== null || empty ($ data [0 ])) {
4551 throw new Exception ('Request failed ( ' . $ this ->client ->getErrors () . ') ' );
4652 }
53+
4754 $ json = json_decode ($ data [0 ], true );
55+
4856 return $ this ->hydrate ($ json );
4957 }
50- }
58+ }
You can’t perform that action at this time.
0 commit comments