Coverage index

src/Service/LocationService.php

Lines: 100.00%

LineHitsSource
1
<?php
2
3
namespace Drupal\visitors\Service;
4
5
use Drupal\Component\Render\MarkupInterface;
6
use Drupal\Core\StringTranslation\StringTranslationTrait;
7
use Drupal\Core\StringTranslation\TranslationInterface;
8
use Drupal\visitors\VisitorsLocationInterface;
9
10
/**
11
 * The location service.
12
 */
13
class LocationService implements VisitorsLocationInterface {
14
  use StringTranslationTrait;
15
16
  /**
17
   * List of countries.
18
   *
19
   * @var array
20
   */
21
  protected $countries = [];
22
23
  /**
24
   * List of continents.
25
   *
26
   * @var array
27
   */
28
  protected $continents = [];
29
30
  /**
31
   * Constructs a new LocationService object.
32
   *
33
   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
34
   *   The string translation service.
35
   */
36
  public function __construct(TranslationInterface $string_translation) {
37
3817
    $this->setStringTranslation($string_translation);
39
4017
    $this->continents = [
4117
      'AF' => $this->t('Africa'),
4217
      'AS' => $this->t('Asia'),
4317
      'EU' => $this->t('Europe'),
4417
      'NA' => $this->t('North America'),
4517
      'OC' => $this->t('Oceania'),
4617
      'SA' => $this->t('South America'),
4717
      'AQ' => $this->t('Antarctica'),
4817
    ];
49
5017
    $this->countries = [
5117
      'AF' => [
5217
        'label' => $this->t('Afghanistan'),
5317
        'continent' => 'AS',
5417
      ],
5517
      'AX' => [
5617
        'label' => $this->t('Aland Islands'),
5717
        'continent' => 'EU',
5817
      ],
5917
      'AL' => [
6017
        'label' => $this->t('Albania'),
6117
        'continent' => 'EU',
6217
      ],
6317
      'DZ' => [
6417
        'label' => $this->t('Algeria'),
6517
        'continent' => 'AF',
6617
      ],
6717
      'AS' => [
6817
        'label' => $this->t('American Samoa'),
6917
        'continent' => 'OC',
7017
      ],
7117
      'AD' => [
7217
        'label' => $this->t('Andorra'),
7317
        'continent' => 'EU',
7417
      ],
7517
      'AO' => [
7617
        'label' => $this->t('Angola'),
7717
        'continent' => 'AF',
7817
      ],
7917
      'AI' => [
8017
        'label' => $this->t('Anguilla'),
8117
        'continent' => 'NA',
8217
      ],
8317
      'AQ' => [
8417
        'label' => $this->t('Antarctica'),
8517
        'continent' => 'AQ',
8617
      ],
8717
      'AG' => [
8817
        'label' => $this->t('Antigua and Barbuda'),
8917
        'continent' => 'NA',
9017
      ],
9117
      'AR' => [
9217
        'label' => $this->t('Argentina'),
9317
        'continent' => 'SA',
9417
      ],
9517
      'AM' => [
9617
        'label' => $this->t('Armenia'),
9717
        'continent' => 'AS',
9817
      ],
9917
      'AW' => [
10017
        'label' => $this->t('Aruba'),
10117
        'continent' => 'SA',
10217
      ],
10317
      'AU' => [
10417
        'label' => $this->t('Australia'),
10517
        'continent' => 'OC',
10617
      ],
10717
      'AT' => [
10817
        'label' => $this->t('Austria'),
10917
        'continent' => 'EU',
11017
      ],
11117
      'AZ' => [
11217
        'label' => $this->t('Azerbaijan'),
11317
        'continent' => 'AS',
11417
      ],
11517
      'BS' => [
11617
        'label' => $this->t('Bahamas'),
11717
        'continent' => 'NA',
11817
      ],
11917
      'BH' => [
12017
        'label' => $this->t('Bahrain'),
12117
        'continent' => 'AS',
12217
      ],
12317
      'BD' => [
12417
        'label' => $this->t('Bangladesh'),
12517
        'continent' => 'AS',
12617
      ],
12717
      'BB' => [
12817
        'label' => $this->t('Barbados'),
12917
        'continent' => 'SA',
13017
      ],
13117
      'BY' => [
13217
        'label' => $this->t('Belarus'),
13317
        'continent' => 'EU',
13417
      ],
13517
      'BE' => [
13617
        'label' => $this->t('Belgium'),
13717
        'continent' => 'EU',
13817
      ],
13917
      'BZ' => [
14017
        'label' => $this->t('Belize'),
14117
        'continent' => 'NA"',
14217
      ],
14317
      'BJ' => [
14417
        'label' => $this->t('Benin'),
14517
        'continent' => 'AF',
14617
      ],
14717
      'BM' => [
14817
        'label' => $this->t('Bermuda'),
14917
        'continent' => 'NA',
15017
      ],
15117
      'BT' => [
15217
        'label' => $this->t('Bhutan'),
15317
        'continent' => 'AS',
15417
      ],
15517
      'BO' => [
15617
        'label' => $this->t('Bolivia'),
15717
        'continent' => 'SA',
15817
      ],
15917
      'BQ' => [
16017
        'label' => $this->t('Bonaire, Sint Eustatius and Saba'),
16117
        'continent' => 'SA',
16217
      ],
16317
      'BA' => [
16417
        'label' => $this->t('Bosnia and Herzegovina'),
16517
        'continent' => 'EU',
16617
      ],
16717
      'BW' => [
16817
        'label' => $this->t('Botswana'),
16917
        'continent' => 'AF',
17017
      ],
17117
      'BV' => [
17217
        'label' => $this->t('Bouvet Island'),
17317
        'continent' => 'SA',
17417
      ],
17517
      'BR' => [
17617
        'label' => $this->t('Brazil'),
17717
        'continent' => 'SA',
17817
      ],
17917
      'IO' => [
18017
        'label' => $this->t('British Indian Ocean Territory'),
18117
        'continent' => 'AF',
18217
      ],
18317
      'BN' => [
18417
        'label' => $this->t('Brunei Darussalam'),
18517
        'continent' => 'AS',
18617
      ],
18717
      'BG' => [
18817
        'label' => $this->t('Bulgaria'),
18917
        'continent' => 'EU',
19017
      ],
19117
      'BF' => [
19217
        'label' => $this->t('Burkina Faso'),
19317
        'continent' => 'AF',
19417
      ],
19517
      'BI' => [
19617
        'label' => $this->t('Burundi'),
19717
        'continent' => 'AF',
19817
      ],
19917
      'CV' => [
20017
        'label' => $this->t('Cabo Verde'),
20117
        'continent' => 'AF',
20217
      ],
20317
      'KH' => [
20417
        'label' => $this->t('Cambodia'),
20517
        'continent' => 'AS',
20617
      ],
20717
      'CM' => [
20817
        'label' => $this->t('Cameroon'),
20917
        'continent' => 'AF',
21017
      ],
21117
      'CA' => [
21217
        'label' => $this->t('Canada'),
21317
        'continent' => 'NA',
21417
      ],
21517
      'KY' => [
21617
        'label' => $this->t('Cayman Islands'),
21717
        'continent' => 'NA',
21817
      ],
21917
      'CF' => [
22017
        'label' => $this->t('Central African Republic'),
22117
        'continent' => 'AF',
22217
      ],
22317
      'TD' => [
22417
        'label' => $this->t('Chad'),
22517
        'continent' => 'AF',
22617
      ],
22717
      'CL' => [
22817
        'label' => $this->t('Chile'),
22917
        'continent' => 'SA',
23017
      ],
23117
      'CN' => [
23217
        'label' => $this->t('China'),
23317
        'continent' => 'AS',
23417
      ],
23517
      'CX' => [
23617
        'label' => $this->t('Christmas Island'),
23717
        'continent' => 'OC',
23817
      ],
23917
      'CC' => [
24017
        'label' => $this->t('Cocos (Keeling) Islands'),
24117
        'continent' => 'OC',
24217
      ],
24317
      'CO' => [
24417
        'label' => $this->t('Colombia'),
24517
        'continent' => 'SA',
24617
      ],
24717
      'KM' => [
24817
        'label' => $this->t('Comoros'),
24917
        'continent' => 'AF',
25017
      ],
25117
      'CG' => [
25217
        'label' => $this->t('Congo'),
25317
        'continent' => 'AF',
25417
      ],
25517
      'CD' => [
25617
        'label' => $this->t('Congo, Democratic Republic of the'),
25717
        'continent' => 'AF',
25817
      ],
25917
      'CK' => [
26017
        'label' => $this->t('Cook Islands'),
26117
        'continent' => 'OC',
26217
      ],
26317
      'CR' => [
26417
        'label' => $this->t('Costa Rica'),
26517
        'continent' => 'NA',
26617
      ],
26717
      'CI' => [
26817
        'label' => $this->t("Côte d'Ivoire"),
26917
        'continent' => 'AF',
27017
      ],
27117
      'HR' => [
27217
        'label' => $this->t('Croatia'),
27317
        'continent' => 'EU',
27417
      ],
27517
      'CU' => [
27617
        'label' => $this->t('Cuba'),
27717
        'continent' => 'NA',
27817
      ],
27917
      'CW' => [
28017
        'label' => $this->t('Curaçao'),
28117
        'continent' => 'SA',
28217
      ],
28317
      'CY' => [
28417
        'label' => $this->t('Cyprus'),
28517
        'continent' => 'AS',
28617
      ],
28717
      'CZ' => [
28817
        'label' => $this->t('Czechia'),
28917
        'continent' => 'EU',
29017
      ],
29117
      'DK' => [
29217
        'label' => $this->t('Denmark'),
29317
        'continent' => 'EU',
29417
      ],
29517
      'DJ' => [
29617
        'label' => $this->t('Djibouti'),
29717
        'continent' => 'AF',
29817
      ],
29917
      'DM' => [
30017
        'label' => $this->t('Dominica'),
30117
        'continent' => 'SA',
30217
      ],
30317
      'DO' => [
30417
        'label' => $this->t('Dominican Republic'),
30517
        'continent' => 'NA',
30617
      ],
30717
      'EC' => [
30817
        'label' => $this->t('Ecuador'),
30917
        'continent' => 'SA',
31017
      ],
31117
      'EG' => [
31217
        'label' => $this->t('Egypt'),
31317
        'continent' => 'AF',
31417
      ],
31517
      'SV' => [
31617
        'label' => $this->t('El Salvador'),
31717
        'continent' => 'SA',
31817
      ],
31917
      'GQ' => [
32017
        'label' => $this->t('Equatorial Guinea'),
32117
        'continent' => 'AF',
32217
      ],
32317
      'ER' => [
32417
        'label' => $this->t('Eritrea'),
32517
        'continent' => 'AF',
32617
      ],
32717
      'EE' => [
32817
        'label' => $this->t('Estonia'),
32917
        'continent' => 'EU',
33017
      ],
33117
      'SZ' => [
33217
        'label' => $this->t('Eswatini'),
33317
        'continent' => 'AF',
33417
      ],
33517
      'ET' => [
33617
        'label' => $this->t('Ethiopia'),
33717
        'continent' => 'AF',
33817
      ],
33917
      'FK' => [
34017
        'label' => $this->t('Falkland Islands (Malvinas)'),
34117
        'continent' => 'SA',
34217
      ],
34317
      'FO' => [
34417
        'label' => $this->t('Faroe Islands'),
34517
        'continent' => 'EU',
34617
      ],
34717
      'FJ' => [
34817
        'label' => $this->t('Fiji'),
34917
        'continent' => 'OC',
35017
      ],
35117
      'FI' => [
35217
        'label' => $this->t('Finland'),
35317
        'continent' => 'EU',
35417
      ],
35517
      'FR' => [
35617
        'label' => $this->t('France'),
35717
        'continent' => 'EU',
35817
      ],
35917
      'GF' => [
36017
        'label' => $this->t('French Guiana'),
36117
        'continent' => 'SA',
36217
      ],
36317
      'PF' => [
36417
        'label' => $this->t('French Polynesia'),
36517
        'continent' => 'OC',
36617
      ],
36717
      'TF' => [
36817
        'label' => $this->t('French Southern Territories'),
36917
        'continent' => 'AF',
37017
      ],
37117
      'GA' => [
37217
        'label' => $this->t('Gabon'),
37317
        'continent' => 'AF',
37417
      ],
37517
      'GM' => [
37617
        'label' => $this->t('Gambia'),
37717
        'continent' => 'AF',
37817
      ],
37917
      'GE' => [
38017
        'label' => $this->t('Georgia'),
38117
        'continent' => 'AS',
38217
      ],
38317
      'DE' => [
38417
        'label' => $this->t('Germany'),
38517
        'continent' => 'EU',
38617
      ],
38717
      'GH' => [
38817
        'label' => $this->t('Ghana'),
38917
        'continent' => 'AF',
39017
      ],
39117
      'GI' => [
39217
        'label' => $this->t('Gibraltar'),
39317
        'continent' => 'EU',
39417
      ],
39517
      'GR' => [
39617
        'label' => $this->t('Greece'),
39717
        'continent' => 'EU',
39817
      ],
39917
      'GL' => [
40017
        'label' => $this->t('Greenland'),
40117
        'continent' => 'NA',
40217
      ],
40317
      'GD' => [
40417
        'label' => $this->t('Grenada'),
40517
        'continent' => 'SA',
40617
      ],
40717
      'GP' => [
40817
        'label' => $this->t('Guadeloupe'),
40917
        'continent' => 'SA',
41017
      ],
41117
      'GU' => [
41217
        'label' => $this->t('Guam'),
41317
        'continent' => 'OC',
41417
      ],
41517
      'GT' => [
41617
        'label' => $this->t('Guatemala'),
41717
        'continent' => 'NA',
41817
      ],
41917
      'GG' => [
42017
        'label' => $this->t('Guernsey'),
42117
        'continent' => 'EU',
42217
      ],
42317
      'GN' => [
42417
        'label' => $this->t('Guinea'),
42517
        'continent' => 'AF',
42617
      ],
42717
      'GW' => [
42817
        'label' => $this->t('Guinea-Bissau'),
42917
        'continent' => 'AF',
43017
      ],
43117
      'GY' => [
43217
        'label' => $this->t('Guyana'),
43317
        'continent' => 'SA',
43417
      ],
43517
      'HT' => [
43617
        'label' => $this->t('Haiti'),
43717
        'continent' => 'NA',
43817
      ],
43917
      'HM' => [
44017
        'label' => $this->t('Heard Island and McDonald Islands'),
44117
        'continent' => 'OC',
44217
      ],
44317
      'VA' => [
44417
        'label' => $this->t('Holy See'),
44517
        'continent' => 'EU',
44617
      ],
44717
      'HN' => [
44817
        'label' => $this->t('Honduras'),
44917
        'continent' => 'NA',
45017
      ],
45117
      'HK' => [
45217
        'label' => $this->t('Hong Kong'),
45317
        'continent' => 'AS',
45417
      ],
45517
      'HU' => [
45617
        'label' => $this->t('Hungary'),
45717
        'continent' => 'EU',
45817
      ],
45917
      'IS' => [
46017
        'label' => $this->t('Iceland'),
46117
        'continent' => 'EU',
46217
      ],
46317
      'IN' => [
46417
        'label' => $this->t('India'),
46517
        'continent' => 'AS',
46617
      ],
46717
      'ID' => [
46817
        'label' => $this->t('Indonesia'),
46917
        'continent' => 'AS',
47017
      ],
47117
      'IR' => [
47217
        'label' => $this->t('Iran'),
47317
        'continent' => 'AS',
47417
      ],
47517
      'IQ' => [
47617
        'label' => $this->t('Iraq'),
47717
        'continent' => 'AS',
47817
      ],
47917
      'IE' => [
48017
        'label' => $this->t('Ireland'),
48117
        'continent' => 'EU',
48217
      ],
48317
      'IM' => [
48417
        'label' => $this->t('Isle of Man'),
48517
        'continent' => 'EU',
48617
      ],
48717
      'IL' => [
48817
        'label' => $this->t('Israel'),
48917
        'continent' => 'AS',
49017
      ],
49117
      'IT' => [
49217
        'label' => $this->t('Italy'),
49317
        'continent' => 'EU',
49417
      ],
49517
      'JM' => [
49617
        'label' => $this->t('Jamaica'),
49717
        'continent' => 'NA',
49817
      ],
49917
      'JP' => [
50017
        'label' => $this->t('Japan'),
50117
        'continent' => 'AS',
50217
      ],
50317
      'JE' => [
50417
        'label' => $this->t('Jersey'),
50517
        'continent' => 'EU',
50617
      ],
50717
      'JO' => [
50817
        'label' => $this->t('Jordan'),
50917
        'continent' => 'AS',
51017
      ],
51117
      'KZ' => [
51217
        'label' => $this->t('Kazakhstan'),
51317
        'continent' => 'AS',
51417
      ],
51517
      'KE' => [
51617
        'label' => $this->t('Kenya,KE,AF'),
51717
        'continent' => 'AF',
51817
      ],
51917
      'KI' => [
52017
        'label' => $this->t('Kiribati'),
52117
        'continent' => 'OC',
52217
      ],
52317
      'KP' => [
52417
        'label' => $this->t("Korea (Democratic People's Republic of)"),
52517
        'continent' => 'AS',
52617
      ],
52717
      'KR' => [
52817
        'label' => $this->t('Korea, Republic of'),
52917
        'continent' => 'AS',
53017
      ],
53117
      'KW' => [
53217
        'label' => $this->t('Kuwait'),
53317
        'continent' => 'AS',
53417
      ],
53517
      'KG' => [
53617
        'label' => $this->t('Kyrgyzstan'),
53717
        'continent' => 'AS',
53817
      ],
53917
      'LA' => [
54017
        'label' => $this->t("Lao People's Democratic Republic"),
54117
        'continent' => 'SA',
54217
      ],
54317
      'LV' => [
54417
        'label' => $this->t('Latvia'),
54517
        'continent' => 'EU',
54617
      ],
54717
      'LB' => [
54817
        'label' => $this->t('Lebanon'),
54917
        'continent' => 'AS',
55017
      ],
55117
      'LS' => [
55217
        'label' => $this->t('Lesotho'),
55317
        'continent' => 'AF',
55417
      ],
55517
      'LR' => [
55617
        'label' => $this->t('Liberia'),
55717
        'continent' => 'AF',
55817
      ],
55917
      'LY' => [
56017
        'label' => $this->t('Libya'),
56117
        'continent' => 'AF',
56217
      ],
56317
      'LI' => [
56417
        'label' => $this->t('Liechtenstein'),
56517
        'continent' => 'EU',
56617
      ],
56717
      'LT' => [
56817
        'label' => $this->t('Lithuania'),
56917
        'continent' => 'EU',
57017
      ],
57117
      'LU' => [
57217
        'label' => $this->t('Luxembourg'),
57317
        'continent' => 'EU',
57417
      ],
57517
      'MO' => [
57617
        'label' => $this->t('Macao'),
57717
        'continent' => 'AS',
57817
      ],
57917
      'MG' => [
58017
        'label' => $this->t('Madagascar'),
58117
        'continent' => 'AF',
58217
      ],
58317
      'MW' => [
58417
        'label' => $this->t('Malawi'),
58517
        'continent' => 'AF',
58617
      ],
58717
      'MY' => [
58817
        'label' => $this->t('Malaysia'),
58917
        'continent' => 'AS',
59017
      ],
59117
      'MV' => [
59217
        'label' => $this->t('Maldives'),
59317
        'continent' => 'AS',
59417
      ],
59517
      'ML' => [
59617
        'label' => $this->t('Mali'),
59717
        'continent' => 'AF',
59817
      ],
59917
      'MT' => [
60017
        'label' => $this->t('Malta'),
60117
        'continent' => 'EU',
60217
      ],
60317
      'MH' => [
60417
        'label' => $this->t('Marshall Islands'),
60517
        'continent' => 'OC',
60617
      ],
60717
      'MQ' => [
60817
        'label' => $this->t('Martinique'),
60917
        'continent' => 'SA',
61017
      ],
61117
      'MR' => [
61217
        'label' => $this->t('Mauritania'),
61317
        'continent' => 'AF',
61417
      ],
61517
      'MU' => [
61617
        'label' => $this->t('Mauritius'),
61717
        'continent' => 'AF',
61817
      ],
61917
      'YT' => [
62017
        'label' => $this->t('Mayotte'),
62117
        'continent' => 'AF',
62217
      ],
62317
      'MX' => [
62417
        'label' => $this->t('Mexico'),
62517
        'continent' => 'NA',
62617
      ],
62717
      'FM' => [
62817
        'label' => $this->t('Micronesia (Federated States of)'),
62917
        'continent' => 'OC',
63017
      ],
63117
      'MD' => [
63217
        'label' => $this->t('Moldova, Republic of'),
63317
        'continent' => 'EU',
63417
      ],
63517
      'MC' => [
63617
        'label' => $this->t('Monaco'),
63717
        'continent' => 'EU',
63817
      ],
63917
      'MN' => [
64017
        'label' => $this->t('Mongolia'),
64117
        'continent' => 'AS',
64217
      ],
64317
      'ME' => [
64417
        'label' => $this->t('Montenegro'),
64517
        'continent' => 'EU',
64617
      ],
64717
      'MS' => [
64817
        'label' => $this->t('Montserrat'),
64917
        'continent' => 'SA',
65017
      ],
65117
      'MA' => [
65217
        'label' => $this->t('Morocco'),
65317
        'continent' => 'AF',
65417
      ],
65517
      'MZ' => [
65617
        'label' => $this->t('Mozambique'),
65717
        'continent' => 'AF',
65817
      ],
65917
      'MM' => [
66017
        'label' => $this->t('Myanmar'),
66117
        'continent' => 'AS',
66217
      ],
66317
      'NA' => [
66417
        'label' => $this->t('Namibia'),
66517
        'continent' => 'AF',
66617
      ],
66717
      'NR' => [
66817
        'label' => $this->t('Nauru'),
66917
        'continent' => 'OC',
67017
      ],
67117
      'NP' => [
67217
        'label' => $this->t('Nepal'),
67317
        'continent' => 'AS',
67417
      ],
67517
      'NL' => [
67617
        'label' => $this->t('Netherlands'),
67717
        'continent' => 'EU',
67817
      ],
67917
      'NC' => [
68017
        'label' => $this->t('New Caledonia'),
68117
        'continent' => 'OC',
68217
      ],
68317
      'NZ' => [
68417
        'label' => $this->t('New Zealand'),
68517
        'continent' => 'OC',
68617
      ],
68717
      'NI' => [
68817
        'label' => $this->t('Nicaragua'),
68917
        'continent' => 'NA',
69017
      ],
69117
      'NE' => [
69217
        'label' => $this->t('Niger'),
69317
        'continent' => 'AF',
69417
      ],
69517
      'NG' => [
69617
        'label' => $this->t('Nigeria'),
69717
        'continent' => 'AF',
69817
      ],
69917
      'NU' => [
70017
        'label' => $this->t('Niue'),
70117
        'continent' => 'OC',
70217
      ],
70317
      'NF' => [
70417
        'label' => $this->t('Norfolk Island'),
70517
        'continent' => 'OC',
70617
      ],
70717
      'MK' => [
70817
        'label' => $this->t('North Macedonia'),
70917
        'continent' => 'EU',
71017
      ],
71117
      'MP' => [
71217
        'label' => $this->t('Northern Mariana Islands'),
71317
        'continent' => 'OC',
71417
      ],
71517
      'NO' => [
71617
        'label' => $this->t('Norway'),
71717
        'continent' => 'EU',
71817
      ],
71917
      'OM' => [
72017
        'label' => $this->t('Oman'),
72117
        'continent' => 'AS',
72217
      ],
72317
      'PK' => [
72417
        'label' => $this->t('Pakistan'),
72517
        'continent' => 'AS',
72617
      ],
72717
      'PW' => [
72817
        'label' => $this->t('Palau'),
72917
        'continent' => 'OC',
73017
      ],
73117
      'PS' => [
73217
        'label' => $this->t('Palestine'),
73317
        'continent' => 'AS',
73417
      ],
73517
      'PA' => [
73617
        'label' => $this->t('Panama'),
73717
        'continent' => 'NA',
73817
      ],
73917
      'PG' => [
74017
        'label' => $this->t('Papua New Guinea'),
74117
        'continent' => 'OC',
74217
      ],
74317
      'PY' => [
74417
        'label' => $this->t('Paraguay'),
74517
        'continent' => 'SA',
74617
      ],
74717
      'PE' => [
74817
        'label' => $this->t('Peru'),
74917
        'continent' => 'SA',
75017
      ],
75117
      'PH' => [
75217
        'label' => $this->t('Philippines'),
75317
        'continent' => 'AS',
75417
      ],
75517
      'PN' => [
75617
        'label' => $this->t('Pitcairn'),
75717
        'continent' => 'OC',
75817
      ],
75917
      'PL' => [
76017
        'label' => $this->t('Poland'),
76117
        'continent' => 'EU',
76217
      ],
76317
      'PT' => [
76417
        'label' => $this->t('Portugal'),
76517
        'continent' => 'EU',
76617
      ],
76717
      'PR' => [
76817
        'label' => $this->t('Puerto Rico'),
76917
        'continent' => 'NA',
77017
      ],
77117
      'QA' => [
77217
        'label' => $this->t('Qatar'),
77317
        'continent' => 'AS',
77417
      ],
77517
      'RE' => [
77617
        'label' => $this->t('Réunion'),
77717
        'continent' => 'AF',
77817
      ],
77917
      'RO' => [
78017
        'label' => $this->t('Romania'),
78117
        'continent' => 'EU',
78217
      ],
78317
      'RU' => [
78417
        'label' => $this->t('Russia'),
78517
        'continent' => 'EU',
78617
      ],
78717
      'RW' => [
78817
        'label' => $this->t('Rwanda'),
78917
        'continent' => 'AF',
79017
      ],
79117
      'BL' => [
79217
        'label' => $this->t('Saint Barthélemy'),
79317
        'continent' => 'SA',
79417
      ],
79517
      'SH' => [
79617
        'label' => $this->t('Saint Helena, Ascension and Tristan da Cunha'),
79717
        'continent' => 'AF',
79817
      ],
79917
      'KN' => [
80017
        'label' => $this->t('Saint Kitts and Nevis'),
80117
        'continent' => 'SA',
80217
      ],
80317
      'LC' => [
80417
        'label' => $this->t('Saint Lucia'),
80517
        'continent' => 'SA',
80617
      ],
80717
      'MF' => [
80817
        'label' => $this->t('Saint Martin (French part)'),
80917
        'continent' => 'SA',
81017
      ],
81117
      'PM' => [
81217
        'label' => $this->t('Saint Pierre and Miquelon'),
81317
        'continent' => 'NA',
81417
      ],
81517
      'VC' => [
81617
        'label' => $this->t('Saint Vincent and the Grenadines'),
81717
        'continent' => 'SA',
81817
      ],
81917
      'WS' => [
82017
        'label' => $this->t('Samoa'),
82117
        'continent' => 'OC',
82217
      ],
82317
      'SM' => [
82417
        'label' => $this->t('San Marino'),
82517
        'continent' => 'EU',
82617
      ],
82717
      'ST' => [
82817
        'label' => $this->t('Sao Tome and Principe'),
82917
        'continent' => 'AF',
83017
      ],
83117
      'SA' => [
83217
        'label' => $this->t('Saudi Arabia'),
83317
        'continent' => 'AS',
83417
      ],
83517
      'SN' => [
83617
        'label' => $this->t('Senegal'),
83717
        'continent' => 'AF',
83817
      ],
83917
      'RS' => [
84017
        'label' => $this->t('Serbia'),
84117
        'continent' => 'EU',
84217
      ],
84317
      'SC' => [
84417
        'label' => $this->t('Seychelles'),
84517
        'continent' => 'AF',
84617
      ],
84717
      'SL' => [
84817
        'label' => $this->t('Sierra Leone'),
84917
        'continent' => 'AF',
85017
      ],
85117
      'SG' => [
85217
        'label' => $this->t('Singapore'),
85317
        'continent' => 'AS',
85417
      ],
85517
      'SX' => [
85617
        'label' => $this->t('Sint Maarten (Dutch part)'),
85717
        'continent' => 'SA',
85817
      ],
85917
      'SK' => [
86017
        'label' => $this->t('Slovakia'),
86117
        'continent' => 'EU',
86217
      ],
86317
      'SI' => [
86417
        'label' => $this->t('Slovenia'),
86517
        'continent' => 'EU',
86617
      ],
86717
      'SB' => [
86817
        'label' => $this->t('Solomon Islands'),
86917
        'continent' => 'OC',
87017
      ],
87117
      'SO' => [
87217
        'label' => $this->t('Somalia'),
87317
        'continent' => 'AF',
87417
      ],
87517
      'ZA' => [
87617
        'label' => $this->t('South Africa'),
87717
        'continent' => 'AF',
87817
      ],
87917
      'GS' => [
88017
        'label' => $this->t('South Georgia and the South Sandwich Islands'),
88117
        'continent' => 'SA',
88217
      ],
88317
      'SS' => [
88417
        'label' => $this->t('South Sudan'),
88517
        'continent' => 'AF',
88617
      ],
88717
      'ES' => [
88817
        'label' => $this->t('Spain'),
88917
        'continent' => 'EU',
89017
      ],
89117
      'LK' => [
89217
        'label' => $this->t('Sri Lanka'),
89317
        'continent' => 'AS',
89417
      ],
89517
      'SD' => [
89617
        'label' => $this->t('Sudan'),
89717
        'continent' => 'AF',
89817
      ],
89917
      'SR' => [
90017
        'label' => $this->t('Suriname'),
90117
        'continent' => 'SA',
90217
      ],
90317
      'SJ' => [
90417
        'label' => $this->t('Svalbard and Jan Mayen'),
90517
        'continent' => 'EU',
90617
      ],
90717
      'SE' => [
90817
        'label' => $this->t('Sweden'),
90917
        'continent' => 'EU',
91017
      ],
91117
      'CH' => [
91217
        'label' => $this->t('Switzerland'),
91317
        'continent' => 'EU',
91417
      ],
91517
      'SY' => [
91617
        'label' => $this->t('Syria'),
91717
        'continent' => 'AS',
91817
      ],
91917
      'TW' => [
92017
        'label' => $this->t('Taiwan'),
92117
        'continent' => 'AS',
92217
      ],
92317
      'TJ' => [
92417
        'label' => $this->t('Tajikistan'),
92517
        'continent' => 'AS',
92617
      ],
92717
      'TZ' => [
92817
        'label' => $this->t('Tanzania'),
92917
        'continent' => 'AF',
93017
      ],
93117
      'TH' => [
93217
        'label' => $this->t('Thailand'),
93317
        'continent' => 'AS',
93417
      ],
93517
      'TL' => [
93617
        'label' => $this->t('Timor-Leste'),
93717
        'continent' => 'AS',
93817
      ],
93917
      'TG' => [
94017
        'label' => $this->t('Togo'),
94117
        'continent' => 'AF',
94217
      ],
94317
      'TK' => [
94417
        'label' => $this->t('Tokelau'),
94517
        'continent' => 'OC',
94617
      ],
94717
      'TO' => [
94817
        'label' => $this->t('Tonga'),
94917
        'continent' => 'OC',
95017
      ],
95117
      'TT' => [
95217
        'label' => $this->t('Trinidad and Tobago'),
95317
        'continent' => 'SA',
95417
      ],
95517
      'TN' => [
95617
        'label' => $this->t('Tunisia'),
95717
        'continent' => 'AF',
95817
      ],
95917
      'TR' => [
96017
        'label' => $this->t('Turkey'),
96117
        'continent' => 'AS',
96217
      ],
96317
      'TM' => [
96417
        'label' => $this->t('Turkmenistan'),
96517
        'continent' => 'AS',
96617
      ],
96717
      'TC' => [
96817
        'label' => $this->t('Turks and Caicos Islands'),
96917
        'continent' => 'NA',
97017
      ],
97117
      'TV' => [
97217
        'label' => $this->t('Tuvalu'),
97317
        'continent' => 'OC',
97417
      ],
97517
      'UG' => [
97617
        'label' => $this->t('Uganda'),
97717
        'continent' => 'AF',
97817
      ],
97917
      'UA' => [
98017
        'label' => $this->t('Ukraine'),
98117
        'continent' => 'EU',
98217
      ],
98317
      'AE' => [
98417
        'label' => $this->t('United Arab Emirates'),
98517
        'continent' => 'AS',
98617
      ],
98717
      'GB' => [
98817
        'label' => $this->t('United Kingdom'),
98917
        'continent' => 'EU',
99017
      ],
99117
      'US' => [
99217
        'label' => $this->t('United States'),
99317
        'continent' => 'NA',
99417
      ],
99517
      'UM' => [
99617
        'label' => $this->t('United States Minor Outlying Islands'),
99717
        'continent' => 'OC',
99817
      ],
99917
      'UY' => [
100017
        'label' => $this->t('Uruguay'),
100117
        'continent' => 'SA',
100217
      ],
100317
      'UZ' => [
100417
        'label' => $this->t('Uzbekistan'),
100517
        'continent' => 'AS',
100617
      ],
100717
      'VU' => [
100817
        'label' => $this->t('Vanuatu'),
100917
        'continent' => 'OC',
101017
      ],
101117
      'VE' => [
101217
        'label' => $this->t('Venezuela'),
101317
        'continent' => 'SA',
101417
      ],
101517
      'VN' => [
101617
        'label' => $this->t('Vietnam'),
101717
        'continent' => 'AS',
101817
      ],
101917
      'VG' => [
102017
        'label' => $this->t('Virgin Islands, British'),
102117
        'continent' => 'NA',
102217
      ],
102317
      'VI' => [
102417
        'label' => $this->t('Virgin Islands, US'),
102517
        'continent' => 'NA',
102617
      ],
102717
      'WF' => [
102817
        'label' => $this->t('Wallis and Futuna'),
102917
        'continent' => 'OC',
103017
      ],
103117
      'EH' => [
103217
        'label' => $this->t('Western Sahara'),
103317
        'continent' => 'AF',
103417
      ],
103517
      'YE' => [
103617
        'label' => $this->t('Yemen'),
103717
        'continent' => 'AS',
103817
      ],
103917
      'ZM' => [
104017
        'label' => $this->t('Zambia'),
104117
        'continent' => 'AF',
104217
      ],
104317
      'ZW' => [
104417
        'label' => $this->t('Zimbabwe'),
104517
        'continent' => 'AF',
104617
      ],
104717
    ];
1048
  }
1049
1050
  /**
1051
   * {@inheritdoc}
1052
   */
1053
  public function getCountryLabel($country_code): MarkupInterface {
10543
    $country_code = strtoupper($country_code);
10553
    return $this->countries[$country_code]['label'] ?? $this->t('Unknown');
1056
  }
1057
1058
  /**
1059
   * {@inheritdoc}
1060
   */
1061
  public function getContinent($country_code): string {
10626
    $country_code = strtoupper($country_code);
10636
    return $this->countries[$country_code]['continent'] ?? '';
1064
  }
1065
1066
  /**
1067
   * {@inheritdoc}
1068
   */
1069
  public function getContinentLabel($continent_code): MarkupInterface {
10701
    $continent_code = strtoupper($continent_code);
10711
    return $this->continents[$continent_code] ?? $this->t('Unknown');
1072
  }
1073
1074
  /**
1075
   * {@inheritdoc}
1076
   */
1077
  public function isValidCountryCode($country_code): bool {
107811
    $country_code = strtoupper($country_code);
107911
    return isset($this->countries[$country_code]);
1080
  }
1081
1082
}