Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — 1.1 (#1071)
by
unknown
05:34
created

Tld::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 3
cts 5
cp 0.6
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.2559
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Rules;
13
14
class Tld extends AbstractRule
15
{
16
    protected $tldList = [
17
        //generic - http://en.wikipedia.org/wiki/Generic_top-level_domain
18
        'aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info',
19
        'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'post', 'pro',
20
        'tel', 'travel', 'xxx', 'ninja', 'abb', 'abbott', 'abogado', 'academy',
21
        'accenture', 'accountant', 'accountants', 'active', 'actor', 'ads', 'adult',
22
        'aeg', 'afl', 'agency', 'aig', 'airforce', 'allfinanz', 'alsace', 'amsterdam',
23
        'an', 'android', 'apartments', 'app', 'aquarelle', 'archi', 'army', 'arpa',
24
        'associates', 'attorney', 'auction', 'audio', 'auto', 'autos', 'axa', 'azure',
25
        'band', 'bank', 'bar', 'barclaycard', 'barclays', 'bargains', 'bauhaus',
26
        'bayern', 'bbc', 'bbva', 'beer', 'berlin', 'best', 'bharti', 'bible', 'bid',
27
        'bike', 'bing', 'bingo', 'bio', 'black', 'blackfriday', 'bloomberg', 'blue',
28
        'bmw', 'bnl', 'bnpparibas', 'boats', 'bond', 'boo', 'boutique', 'bradesco',
29
        'bridgestone', 'broker', 'brother', 'brussels', 'budapest', 'build', 'builders',
30
        'business', 'buzz', 'bv', 'bzh', 'cab', 'cafe', 'cal', 'camera', 'camp',
31
        'cancerresearch', 'canon', 'capetown', 'capital', 'caravan', 'cards',
32
        'care', 'career', 'careers', 'cars', 'cartier', 'casa', 'cash', 'casino',
33
        'catering', 'cba', 'cbn', 'center', 'ceo', 'cern', 'cfa', 'cfd', 'channel',
34
        'chat', 'cheap', 'chloe', 'christmas', 'chrome', 'church', 'cisco', 'citic',
35
        'city', 'claims', 'cleaning', 'click', 'clinic', 'clothing', 'cloud', 'club',
36
        'coach', 'codes', 'coffee', 'college', 'cologne', 'commbank', 'community',
37
        'company', 'computer', 'condos', 'construction', 'consulting', 'contractors',
38
        'cooking', 'cool', 'corsica', 'country', 'coupons', 'courses', 'credit',
39
        'creditcard', 'cricket', 'crown', 'crs', 'cruises', 'cuisinella', 'cw',
40
        'cymru', 'cyou', 'dabur', 'dad', 'dance', 'date', 'dating', 'datsun',
41
        'day', 'dclk', 'deals', 'degree', 'delivery', 'democrat', 'dental', 'dentist'
42
        , 'desi', 'design', 'dev', 'diamonds', 'diet', 'digital', 'direct', 'directory',
43
        'discount', 'dnp', 'docs', 'dog', 'doha', 'domains', 'doosan', 'download',
44
        'drive', 'durban', 'dvag', 'earth', 'eat', 'education', 'email', 'emerck',
45
        'energy', 'engineer', 'engineering', 'enterprises', 'epson', 'equipment',
46
        'erni', 'esq', 'estate', 'eurovision', 'eus', 'events', 'everbank',
47
        'exchange', 'expert', 'exposed', 'express', 'fail', 'faith', 'fan', 'fans',
48
        'farm', 'fashion', 'feedback', 'film', 'finance', 'financial', 'firmdale',
49
        'fish', 'fishing', 'fit', 'fitness', 'flights', 'florist', 'flowers', 'flsmidth',
50
        'fly', 'foo', 'football', 'forex', 'forsale', 'forum', 'foundation', 'frl',
51
        'frogans', 'fund', 'furniture', 'futbol', 'fyi', 'gal', 'gallery', 'garden',
52
        'gbiz', 'gdn', 'gent', 'genting', 'ggee', 'gift', 'gifts', 'gives', 'glass',
53
        'gle', 'global', 'globo', 'gmail', 'gmo', 'gmx', 'gold', 'goldpoint', 'golf',
54
        'goo', 'goog', 'google', 'gop', 'graphics', 'gratis', 'green', 'gripe', 'guge',
55
        'guide', 'guitars', 'guru', 'hamburg', 'hangout', 'haus', 'healthcare', 'help',
56
        'here', 'hermes', 'hiphop', 'hitachi', 'hiv', 'hockey', 'holdings', 'holiday',
57
        'homedepot', 'homes', 'honda', 'horse', 'host', 'hosting', 'hoteles', 'hotmail',
58
        'house', 'how', 'ibm', 'icbc', 'icu', 'ifm', 'immo', 'immobilien', 'industries',
59
        'infiniti', 'ing', 'ink', 'institute', 'insure', 'international', 'investments',
60
        'irish', 'iwc', 'java', 'jcb', 'jetzt', 'jewelry', 'jlc', 'jll', 'joburg', 'juegos',
61
        'kaufen', 'kddi', 'kim', 'kitchen', 'kiwi', 'koeln', 'komatsu', 'krd', 'kred',
62
        'kyoto', 'lacaixa', 'land', 'lasalle', 'lat', 'latrobe', 'law', 'lawyer', 'lds',
63
        'lease', 'leclerc', 'legal', 'lgbt', 'liaison', 'lidl', 'life', 'lighting',
64
        'limited', 'limo', 'link', 'loan', 'loans', 'lol', 'london', 'lotte', 'lotto',
65
        'love', 'ltda', 'lupin', 'luxe', 'luxury', 'madrid', 'maif', 'maison', 'management',
66
        'mango', 'market', 'marketing', 'markets', 'marriott', 'mba', 'media', 'meet',
67
        'melbourne', 'meme', 'memorial', 'men', 'menu', 'miami', 'microsoft', 'mini', 'mma',
68
        'moda', 'moe', 'monash', 'money', 'montblanc', 'mormon', 'mortgage', 'moscow',
69
        'motorcycles', 'mov', 'movie', 'movistar', 'mtn', 'mtpc', 'nadex', 'nagoya', 'navy',
70
        'nec', 'netbank', 'network', 'neustar', 'new', 'news', 'nexus', 'ngo', 'nhk', 'nico',
71
        'ninja', 'nissan', 'nra', 'nrw', 'ntt', 'nyc', 'office', 'okinawa', 'omega', 'one',
72
        'ong', 'onl', 'online', 'ooo', 'oracle', 'organic', 'osaka', 'otsuka', 'ovh', 'page',
73
        'panerai', 'paris', 'partners', 'parts', 'party', 'pharmacy', 'philips', 'photo',
74
        'photography', 'photos', 'physio', 'piaget', 'pics', 'pictet', 'pictures', 'pink',
75
        'pizza', 'place', 'play', 'plumbing', 'plus', 'pohl', 'poker', 'porn', 'praxi',
76
        'press', 'prod', 'productions', 'prof', 'properties', 'property', 'pub', 'qpon',
77
        'quebec', 'racing', 'realtor', 'realty', 'recipes', 'red', 'redstone', 'rehab',
78
        'reise', 'reisen', 'reit', 'ren', 'rent', 'rentals', 'repair', 'report', 'republican',
79
        'rest', 'restaurant', 'review', 'reviews', 'rich', 'ricoh', 'rio', 'rip', 'rocks',
80
        'rodeo', 'rsvp', 'ruhr', 'run', 'ryukyu', 'saarland', 'sakura', 'sale', 'samsung',
81
        'sandvik', 'sandvikcoromant', 'sap', 'sarl', 'saxo', 'sca', 'scb', 'schmidt',
82
        'scholarships', 'school', 'schule', 'schwarz', 'science', 'scor', 'scot', 'seat',
83
        'sener', 'services', 'sew', 'sex', 'sexy', 'shiksha', 'shoes', 'show', 'shriram',
84
        'singles', 'site', 'sj', 'ski', 'sky', 'skype', 'sncf', 'soccer', 'social',
85
        'software', 'sohu', 'solar', 'solutions', 'sony', 'soy', 'space', 'spiegel',
86
        'spreadbetting', 'starhub', 'statoil', 'studio', 'study', 'style', 'sucks', 'supplies',
87
        'supply', 'support', 'surf', 'surgery', 'suzuki', 'swatch', 'swiss', 'sx', 'sydney',
88
        'systems', 'taipei', 'tatar', 'tattoo', 'tax', 'taxi', 'team', 'tech', 'technology',
89
        'telefonica', 'temasek', 'tennis', 'thd', 'theater', 'tickets', 'tienda', 'tips',
90
        'tires', 'tirol', 'today', 'tokyo', 'tools', 'top', 'toray', 'toshiba', 'tours',
91
        'town', 'toys', 'trade', 'trading', 'training', 'trust', 'tui', 'university', 'uno',
92
        'uol', 'vacations', 'vegas', 'ventures', 'versicherung', 'vet', 'viajes', 'video',
93
        'villas', 'vision', 'vista', 'vistaprint', 'vlaanderen', 'vodka', 'vote', 'voting',
94
        'voto', 'voyage', 'wales', 'walter', 'wang', 'watch', 'webcam', 'website', 'wed',
95
        'wedding', 'weir', 'whoswho', 'wien', 'wiki', 'williamhill', 'win', 'windows',
96
        'wme', 'work', 'works', 'world', 'wtc', 'wtf', 'xbox', 'xerox', 'xin', 'xyz',
97
        'yachts', 'yandex', 'yodobashi', 'yoga', 'yokohama', 'youtube', 'zip', 'zone', 'zuerich',
98
        //country
99
        'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'ao', 'aq', 'ar', 'as',
100
        'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh',
101
        'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bw', 'by', 'bz',
102
        'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co',
103
        'cr', 'cs', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do',
104
        'dz', 'ec', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm',
105
        'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm',
106
        'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn',
107
        'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is',
108
        'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp',
109
        'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt',
110
        'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm',
111
        'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my',
112
        'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu',
113
        'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr',
114
        'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb',
115
        'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sk', 'sl', 'sm', 'sn', 'so',
116
        'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj',
117
        'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua',
118
        'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu',
119
        'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw',
120
    ];
121
122 10
    public function validate($input)
123
    {
124
        // prefere LayerShifter\TLDDatabase if available
125 10
        if (class_exists('\LayerShifter\TLDDatabase\Store')) {
126
            $tldDb = new \LayerShifter\TLDDatabase\Store();
127
            return $tldDb->isExists(strtolower($input));
128
        } else {
129 10
            return in_array(strtolower($input), $this->tldList);
130
        }
131
    }
132
}
133