|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Astrotomic\OpenGraph\Types\Twitter; |
| 4 | + |
| 5 | +use Astrotomic\OpenGraph\TwitterType; |
| 6 | + |
| 7 | +class App extends TwitterType |
| 8 | +{ |
| 9 | + /** @var string */ |
| 10 | + protected $type = 'app'; |
| 11 | + |
| 12 | + public function iPhoneApp(string $name, string $iPhoneAppId, ?string $iPhoneAppUrl = null) |
| 13 | + { |
| 14 | + $this->setProperty(self::PREFIX, 'app:name:iphone', $name); |
| 15 | + $this->setProperty(self::PREFIX, 'app:id:iphone', $iPhoneAppId); |
| 16 | + if (empty($iPhoneAppUrl)) { |
| 17 | + if (str_contains($iPhoneAppUrl, "://")) { |
| 18 | + $this->setProperty(self::PREFIX, 'app:url:iphone', $iPhoneAppUrl); |
| 19 | + } |
| 20 | + } |
| 21 | + |
| 22 | + return $this; |
| 23 | + } |
| 24 | + |
| 25 | + public function iPadApp(string $name, string $iPadAppId, ?string $iPadAppUrl = null) |
| 26 | + { |
| 27 | + $this->setProperty(self::PREFIX, 'app:name:ipad', $name); |
| 28 | + $this->setProperty(self::PREFIX, 'app:id:ipad', $iPadAppId); |
| 29 | + if (!empty($iPadAppUrl)) { |
| 30 | + if (str_contains($iPadAppUrl, "://")) { |
| 31 | + $this->setProperty(self::PREFIX, 'app:url:ipad', $iPadAppUrl); |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + return $this; |
| 36 | + } |
| 37 | + |
| 38 | + public function googlePlayApp(string $name, string $googlePlayAppId, ?string $googlePlayAppUrl = null) |
| 39 | + { |
| 40 | + $this->setProperty(self::PREFIX, 'app:name:googleplay', $name); |
| 41 | + $this->setProperty(self::PREFIX, 'app:id:googleplay', $googlePlayAppId); |
| 42 | + if (!empty($googlePlayAppUrl)) { |
| 43 | + if (str_contains($googlePlayAppUrl, "://")) { |
| 44 | + $this->setProperty(self::PREFIX, 'app:url:googleplay', $googlePlayAppUrl); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + return $this; |
| 49 | + } |
| 50 | + |
| 51 | + public function country(string $county = null) |
| 52 | + { |
| 53 | + if (!empty($county)) { |
| 54 | + $county = strtoupper($county); |
| 55 | + if (array_key_exists($county, self::$countries)) { |
| 56 | + $this->setProperty(self::PREFIX, 'app:country', $county); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + return $this; |
| 61 | + } |
| 62 | + |
| 63 | + private static $countries = array( |
| 64 | + "BD" => "Bangladesh", |
| 65 | + "BE" => "Belgium", |
| 66 | + "BF" => "Burkina Faso", |
| 67 | + "BG" => "Bulgaria", |
| 68 | + "BA" => "Bosnia and Herzegovina", |
| 69 | + "BB" => "Barbados", |
| 70 | + "WF" => "Wallis and Futuna", |
| 71 | + "BL" => "Saint Barthelemy", |
| 72 | + "BM" => "Bermuda", |
| 73 | + "BN" => "Brunei", |
| 74 | + "BO" => "Bolivia", |
| 75 | + "BH" => "Bahrain", |
| 76 | + "BI" => "Burundi", |
| 77 | + "BJ" => "Benin", |
| 78 | + "BT" => "Bhutan", |
| 79 | + "JM" => "Jamaica", |
| 80 | + "BV" => "Bouvet Island", |
| 81 | + "BW" => "Botswana", |
| 82 | + "WS" => "Samoa", |
| 83 | + "BQ" => "Bonaire, Saint Eustatius and Saba ", |
| 84 | + "BR" => "Brazil", |
| 85 | + "BS" => "Bahamas", |
| 86 | + "JE" => "Jersey", |
| 87 | + "BY" => "Belarus", |
| 88 | + "BZ" => "Belize", |
| 89 | + "RU" => "Russia", |
| 90 | + "RW" => "Rwanda", |
| 91 | + "RS" => "Serbia", |
| 92 | + "TL" => "East Timor", |
| 93 | + "RE" => "Reunion", |
| 94 | + "TM" => "Turkmenistan", |
| 95 | + "TJ" => "Tajikistan", |
| 96 | + "RO" => "Romania", |
| 97 | + "TK" => "Tokelau", |
| 98 | + "GW" => "Guinea-Bissau", |
| 99 | + "GU" => "Guam", |
| 100 | + "GT" => "Guatemala", |
| 101 | + "GS" => "South Georgia and the South Sandwich Islands", |
| 102 | + "GR" => "Greece", |
| 103 | + "GQ" => "Equatorial Guinea", |
| 104 | + "GP" => "Guadeloupe", |
| 105 | + "JP" => "Japan", |
| 106 | + "GY" => "Guyana", |
| 107 | + "GG" => "Guernsey", |
| 108 | + "GF" => "French Guiana", |
| 109 | + "GE" => "Georgia", |
| 110 | + "GD" => "Grenada", |
| 111 | + "GB" => "United Kingdom", |
| 112 | + "GA" => "Gabon", |
| 113 | + "SV" => "El Salvador", |
| 114 | + "GN" => "Guinea", |
| 115 | + "GM" => "Gambia", |
| 116 | + "GL" => "Greenland", |
| 117 | + "GI" => "Gibraltar", |
| 118 | + "GH" => "Ghana", |
| 119 | + "OM" => "Oman", |
| 120 | + "TN" => "Tunisia", |
| 121 | + "JO" => "Jordan", |
| 122 | + "HR" => "Croatia", |
| 123 | + "HT" => "Haiti", |
| 124 | + "HU" => "Hungary", |
| 125 | + "HK" => "Hong Kong", |
| 126 | + "HN" => "Honduras", |
| 127 | + "HM" => "Heard Island and McDonald Islands", |
| 128 | + "VE" => "Venezuela", |
| 129 | + "PR" => "Puerto Rico", |
| 130 | + "PS" => "Palestinian Territory", |
| 131 | + "PW" => "Palau", |
| 132 | + "PT" => "Portugal", |
| 133 | + "SJ" => "Svalbard and Jan Mayen", |
| 134 | + "PY" => "Paraguay", |
| 135 | + "IQ" => "Iraq", |
| 136 | + "PA" => "Panama", |
| 137 | + "PF" => "French Polynesia", |
| 138 | + "PG" => "Papua New Guinea", |
| 139 | + "PE" => "Peru", |
| 140 | + "PK" => "Pakistan", |
| 141 | + "PH" => "Philippines", |
| 142 | + "PN" => "Pitcairn", |
| 143 | + "PL" => "Poland", |
| 144 | + "PM" => "Saint Pierre and Miquelon", |
| 145 | + "ZM" => "Zambia", |
| 146 | + "EH" => "Western Sahara", |
| 147 | + "EE" => "Estonia", |
| 148 | + "EG" => "Egypt", |
| 149 | + "ZA" => "South Africa", |
| 150 | + "EC" => "Ecuador", |
| 151 | + "IT" => "Italy", |
| 152 | + "VN" => "Vietnam", |
| 153 | + "SB" => "Solomon Islands", |
| 154 | + "ET" => "Ethiopia", |
| 155 | + "SO" => "Somalia", |
| 156 | + "ZW" => "Zimbabwe", |
| 157 | + "SA" => "Saudi Arabia", |
| 158 | + "ES" => "Spain", |
| 159 | + "ER" => "Eritrea", |
| 160 | + "ME" => "Montenegro", |
| 161 | + "MD" => "Moldova", |
| 162 | + "MG" => "Madagascar", |
| 163 | + "MF" => "Saint Martin", |
| 164 | + "MA" => "Morocco", |
| 165 | + "MC" => "Monaco", |
| 166 | + "UZ" => "Uzbekistan", |
| 167 | + "MM" => "Myanmar", |
| 168 | + "ML" => "Mali", |
| 169 | + "MO" => "Macao", |
| 170 | + "MN" => "Mongolia", |
| 171 | + "MH" => "Marshall Islands", |
| 172 | + "MK" => "Macedonia", |
| 173 | + "MU" => "Mauritius", |
| 174 | + "MT" => "Malta", |
| 175 | + "MW" => "Malawi", |
| 176 | + "MV" => "Maldives", |
| 177 | + "MQ" => "Martinique", |
| 178 | + "MP" => "Northern Mariana Islands", |
| 179 | + "MS" => "Montserrat", |
| 180 | + "MR" => "Mauritania", |
| 181 | + "IM" => "Isle of Man", |
| 182 | + "UG" => "Uganda", |
| 183 | + "TZ" => "Tanzania", |
| 184 | + "MY" => "Malaysia", |
| 185 | + "MX" => "Mexico", |
| 186 | + "IL" => "Israel", |
| 187 | + "FR" => "France", |
| 188 | + "IO" => "British Indian Ocean Territory", |
| 189 | + "SH" => "Saint Helena", |
| 190 | + "FI" => "Finland", |
| 191 | + "FJ" => "Fiji", |
| 192 | + "FK" => "Falkland Islands", |
| 193 | + "FM" => "Micronesia", |
| 194 | + "FO" => "Faroe Islands", |
| 195 | + "NI" => "Nicaragua", |
| 196 | + "NL" => "Netherlands", |
| 197 | + "NO" => "Norway", |
| 198 | + "NA" => "Namibia", |
| 199 | + "VU" => "Vanuatu", |
| 200 | + "NC" => "New Caledonia", |
| 201 | + "NE" => "Niger", |
| 202 | + "NF" => "Norfolk Island", |
| 203 | + "NG" => "Nigeria", |
| 204 | + "NZ" => "New Zealand", |
| 205 | + "NP" => "Nepal", |
| 206 | + "NR" => "Nauru", |
| 207 | + "NU" => "Niue", |
| 208 | + "CK" => "Cook Islands", |
| 209 | + "XK" => "Kosovo", |
| 210 | + "CI" => "Ivory Coast", |
| 211 | + "CH" => "Switzerland", |
| 212 | + "CO" => "Colombia", |
| 213 | + "CN" => "China", |
| 214 | + "CM" => "Cameroon", |
| 215 | + "CL" => "Chile", |
| 216 | + "CC" => "Cocos Islands", |
| 217 | + "CA" => "Canada", |
| 218 | + "CG" => "Republic of the Congo", |
| 219 | + "CF" => "Central African Republic", |
| 220 | + "CD" => "Democratic Republic of the Congo", |
| 221 | + "CZ" => "Czech Republic", |
| 222 | + "CY" => "Cyprus", |
| 223 | + "CX" => "Christmas Island", |
| 224 | + "CR" => "Costa Rica", |
| 225 | + "CW" => "Curacao", |
| 226 | + "CV" => "Cape Verde", |
| 227 | + "CU" => "Cuba", |
| 228 | + "SZ" => "Swaziland", |
| 229 | + "SY" => "Syria", |
| 230 | + "SX" => "Sint Maarten", |
| 231 | + "KG" => "Kyrgyzstan", |
| 232 | + "KE" => "Kenya", |
| 233 | + "SS" => "South Sudan", |
| 234 | + "SR" => "Suriname", |
| 235 | + "KI" => "Kiribati", |
| 236 | + "KH" => "Cambodia", |
| 237 | + "KN" => "Saint Kitts and Nevis", |
| 238 | + "KM" => "Comoros", |
| 239 | + "ST" => "Sao Tome and Principe", |
| 240 | + "SK" => "Slovakia", |
| 241 | + "KR" => "South Korea", |
| 242 | + "SI" => "Slovenia", |
| 243 | + "KP" => "North Korea", |
| 244 | + "KW" => "Kuwait", |
| 245 | + "SN" => "Senegal", |
| 246 | + "SM" => "San Marino", |
| 247 | + "SL" => "Sierra Leone", |
| 248 | + "SC" => "Seychelles", |
| 249 | + "KZ" => "Kazakhstan", |
| 250 | + "KY" => "Cayman Islands", |
| 251 | + "SG" => "Singapore", |
| 252 | + "SE" => "Sweden", |
| 253 | + "SD" => "Sudan", |
| 254 | + "DO" => "Dominican Republic", |
| 255 | + "DM" => "Dominica", |
| 256 | + "DJ" => "Djibouti", |
| 257 | + "DK" => "Denmark", |
| 258 | + "VG" => "British Virgin Islands", |
| 259 | + "DE" => "Germany", |
| 260 | + "YE" => "Yemen", |
| 261 | + "DZ" => "Algeria", |
| 262 | + "US" => "United States", |
| 263 | + "UY" => "Uruguay", |
| 264 | + "YT" => "Mayotte", |
| 265 | + "UM" => "United States Minor Outlying Islands", |
| 266 | + "LB" => "Lebanon", |
| 267 | + "LC" => "Saint Lucia", |
| 268 | + "LA" => "Laos", |
| 269 | + "TV" => "Tuvalu", |
| 270 | + "TW" => "Taiwan", |
| 271 | + "TT" => "Trinidad and Tobago", |
| 272 | + "TR" => "Turkey", |
| 273 | + "LK" => "Sri Lanka", |
| 274 | + "LI" => "Liechtenstein", |
| 275 | + "LV" => "Latvia", |
| 276 | + "TO" => "Tonga", |
| 277 | + "LT" => "Lithuania", |
| 278 | + "LU" => "Luxembourg", |
| 279 | + "LR" => "Liberia", |
| 280 | + "LS" => "Lesotho", |
| 281 | + "TH" => "Thailand", |
| 282 | + "TF" => "French Southern Territories", |
| 283 | + "TG" => "Togo", |
| 284 | + "TD" => "Chad", |
| 285 | + "TC" => "Turks and Caicos Islands", |
| 286 | + "LY" => "Libya", |
| 287 | + "VA" => "Vatican", |
| 288 | + "VC" => "Saint Vincent and the Grenadines", |
| 289 | + "AE" => "United Arab Emirates", |
| 290 | + "AD" => "Andorra", |
| 291 | + "AG" => "Antigua and Barbuda", |
| 292 | + "AF" => "Afghanistan", |
| 293 | + "AI" => "Anguilla", |
| 294 | + "VI" => "U.S. Virgin Islands", |
| 295 | + "IS" => "Iceland", |
| 296 | + "IR" => "Iran", |
| 297 | + "AM" => "Armenia", |
| 298 | + "AL" => "Albania", |
| 299 | + "AO" => "Angola", |
| 300 | + "AQ" => "Antarctica", |
| 301 | + "AS" => "American Samoa", |
| 302 | + "AR" => "Argentina", |
| 303 | + "AU" => "Australia", |
| 304 | + "AT" => "Austria", |
| 305 | + "AW" => "Aruba", |
| 306 | + "IN" => "India", |
| 307 | + "AX" => "Aland Islands", |
| 308 | + "AZ" => "Azerbaijan", |
| 309 | + "IE" => "Ireland", |
| 310 | + "ID" => "Indonesia", |
| 311 | + "UA" => "Ukraine", |
| 312 | + "QA" => "Qatar", |
| 313 | + "MZ" => "Mozambique" |
| 314 | + ); |
| 315 | +} |
0 commit comments