geo.php
3 years ago
page.php
3 years ago
page_author_archive.php
3 years ago
page_date_archive.php
3 years ago
page_home.php
3 years ago
page_not_found.php
3 years ago
page_post_type_archive.php
3 years ago
page_search.php
3 years ago
page_singular.php
3 years ago
page_term_archive.php
3 years ago
referrer.php
3 years ago
visitor.php
3 years ago
geo.php
83 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP; |
| 4 | |
| 5 | class Geo |
| 6 | { |
| 7 | private $continent; |
| 8 | private $country; |
| 9 | private $country_code; |
| 10 | private $subdivision; |
| 11 | private $city; |
| 12 | private $views; |
| 13 | private $visitors; |
| 14 | private $visitor_ids; |
| 15 | |
| 16 | public function __construct($continent, $country, $country_code, $subdivision, $city, $views, $visitors, $visitor_ids) |
| 17 | { |
| 18 | $this->continent = $continent; |
| 19 | $this->country = $country; |
| 20 | $this->country_code = $country_code; |
| 21 | $this->subdivision = $subdivision; |
| 22 | $this->city = $city; |
| 23 | $this->views = $views; |
| 24 | $this->visitors = $visitors; |
| 25 | $this->visitor_ids = $visitor_ids; |
| 26 | } |
| 27 | |
| 28 | protected function ids() |
| 29 | { |
| 30 | return $this->visitor_ids; |
| 31 | } |
| 32 | |
| 33 | public function continent() |
| 34 | { |
| 35 | return $this->continent; |
| 36 | } |
| 37 | |
| 38 | public function country() |
| 39 | { |
| 40 | return $this->country; |
| 41 | } |
| 42 | |
| 43 | public function flag() |
| 44 | { |
| 45 | $img_name = strtolower($this->country_code); |
| 46 | |
| 47 | return url_to("img/flags/$img_name.svg"); |
| 48 | } |
| 49 | |
| 50 | public function subdivision() |
| 51 | { |
| 52 | return $this->subdivision; |
| 53 | } |
| 54 | |
| 55 | public function city() |
| 56 | { |
| 57 | return $this->city; |
| 58 | } |
| 59 | |
| 60 | public function views() |
| 61 | { |
| 62 | return $this->views; |
| 63 | } |
| 64 | |
| 65 | public function visitors() |
| 66 | { |
| 67 | return $this->visitors; |
| 68 | } |
| 69 | |
| 70 | public static function geo_ids(array $geos): array |
| 71 | { |
| 72 | if (count($geos) === 0) { |
| 73 | return []; |
| 74 | } |
| 75 | |
| 76 | $array_of_arrays = array_map(function ($geo) { |
| 77 | return $geo->ids(); |
| 78 | }, $geos); |
| 79 | |
| 80 | return array_merge(...$array_of_arrays); |
| 81 | } |
| 82 | } |
| 83 |