Subdomain   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 88
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A passes() 0 12 3
A message() 0 4 1
1
<?php
2
3
namespace LVR\Subdomain;
4
5
use Illuminate\Contracts\Validation\Rule;
6
7
/**
8
 * Class Subdomain
9
 *
10
 * @package \LVR\Subdomain
11
 */
12
class Subdomain implements Rule
13
{
14
    /**
15
     * List of reserved subdomains
16
     *
17
     * @var array
18
     */
19
    protected static $reserved = [
20
      'a', 'about', 'aboutu', 'abuse', 'acme', 'ad', 'admanager', 'admin', 'admindashboard', 'administrator', 'ads',
21
      'adsense', 'adult', 'adword', 'adwords', 'affiliate', 'affiliatepage', 'affiliates', 'afp', 'alpha', 'anal',
22
      'analytic', 'android', 'answer', 'anu', 'anus', 'ap', 'api', 'api1', 'api2', 'api3',
23
      'app', 'appengine', 'application', 'appnew', 'arse', 'as', 'asdf', 'ass', 'asset', 'assets',
24
      'assets1', 'assets2', 'assets3', 'assets4', 'assets5', 'asshole', 'atf', 'backup', 'ball', 'balls',
25
      'ballsack', 'bank', 'base', 'bastard', 'beginner', 'beta', 'biatch', 'billing', 'binarie', 'binary',
26
      'bitch', 'biz', 'blackberry', 'blog', 'blogsearch', 'bloody', 'blowjob', 'blowjobs', 'bollock', 'boner',
27
      'boob', 'boobs', 'book', 'bugger', 'bum', 'butt', 'buttplug', 'buy', 'buzz', 'c',
28
      'cache', 'calendar', 'cart', 'catalog', 'ceo', 'chart', 'chat', 'checkout', 'ci', 'cia',
29
      'client', 'clients', 'clitori', 'clitoris', 'cname', 'cnarne', 'cock', 'code', 'community', 'confirm',
30
      'confirmation', 'contact', 'contact-u', 'contactu', 'content', 'controlpanel', 'coon', 'core', 'corp', 'countrie',
31
      'country', 'cp', 'cpanel', 'crap', 'cs', 'css', 'css1', 'css2', 'css3', 'cunt',
32
      'cv', 'damn', 'dashboard', 'data', 'demo', 'deploy', 'deployment', 'desktop', 'dev', 'devel',
33
      'developement', 'developer', 'developers', 'development', 'dick', 'dike', 'dildo', 'dir', 'directory', 'discussion',
34
      'dl', 'doc', 'docs', 'document', 'donate', 'download', 'dyke', 'e', 'earth', 'email',
35
      'enable', 'encrypted', 'engine', 'error', 'errorlog', 'fag', 'faggot', 'fbi', 'feature', 'feck',
36
      'feed', 'feedburner', 'feedproxy', 'feeds', 'felching', 'fellate', 'fellatio', 'file', 'files', 'finance',
37
      'flange', 'folder', 'forgotpassword', 'forum', 'friend', 'ftp', 'fuck', 'fudgepacker', 'fun', 'fusion',
38
      'gadget', 'gear', 'geographic', 'gettingstarted', 'git', 'gitlab', 'gmail', 'go', 'goddamn', 'goto',
39
      'gov', 'graph', 'graphs', 'group', 'hell', 'help', 'home', 'homo', 'html', 'htrnl',
40
      'http', 'https', 'i', 'image', 'images', 'imap', 'img', 'img1', 'img2', 'img3',
41
      'investor', 'invoice', 'invoices', 'io', 'ios', 'ipad', 'iphone', 'irnage', 'irng', 'item',
42
      'j', 'jenkin', 'jerk', 'jira', 'jizz', 'job', 'join', 'js', 'js1', 'js2',
43
      'kb', 'knobend', 'knowledgebase', 'lab', 'labia', 'legal', 'lesbo', 'list', 'lmao', 'lmfao',
44
      'local', 'locale', 'location', 'log', 'login', 'logout', 'logs', 'm', 'mail', 'manage',
45
      'manager', 'map', 'marketing', 'me', 'media', 'message', 'misc', 'mm', 'mms', 'mobile',
46
      'model', 'money', 'movie', 'muff', 'mx', 'my', 'mystore', 'n', 'net', 'network',
47
      'networks', 'new', 'news', 'newsite', 'nigga', 'nigger', 'npm', 'ns', 'ns1', 'ns2',
48
      'ns3', 'ns4', 'ns5', 'omg', 'online', 'order', 'org', 'other', 'p0rn', 'pack',
49
      'packagist', 'page', 'pages', 'partner', 'partnerpage', 'partners', 'password', 'payment', 'payments', 'peni',
50
      'penis', 'people', 'person', 'pi', 'pis', 'piss', 'place', 'podcast', 'policy', 'poop',
51
      'pop', 'pop3', 'popular', 'porn', 'pr0n', 'press', 'pricing', 'prick', 'print', 'privacy',
52
      'private', 'prod', 'product', 'production', 'profile', 'promo', 'promotion', 'proxie', 'proxies', 'proxy',
53
      'pube', 'public', 'purchase', 'pussy', 'queer', 'querie', 'queries', 'query', 'r', 'radio',
54
      'random', 'reader', 'recover', 'redirect', 'register', 'registration', 'release', 'report', 'research', 'resolve',
55
      'resolver', 'rnail', 'rnicrosoft', 'root', 'rs', 'rss', 'sale', 'sandbox', 'scholar', 'scrotum',
56
      'search', 'secure', 'seminar', 'server', 'servers', 'service', 'sex', 'sftp', 'sh1t', 'shit',
57
      'shop', 'shopping', 'shortcut', 'signin', 'signup', 'site', 'sitemap', 'sitenew', 'sitenews', 'sites',
58
      'sketchup', 'sky', 'slash', 'slashinvoice', 'slut', 'sm', 'smegma', 'sms', 'smtp', 'soap',
59
      'software', 'sorry', 'spreadsheet', 'spunk', 'srntp', 'ssh', 'ssl', 'stage', 'staging', 'stat',
60
      'static', 'statistic', 'statistics', 'stats', 'statu', 'status', 'store', 'suggest', 'suggestquerie', 'suggestquery',
61
      'support', 'survey', 'surveys', 'surveytool', 'svn', 'sync', 'sysadmin', 'talk', 'talkgadget', 'test',
62
      'tester', 'testing', 'text', 'tit', 'tits', 'tool', 'toolbar', 'tosser', 'trac', 'translate',
63
      'translation', 'translator', 'trend', 'turd', 'twat', 'txt', 'ul', 'upload', 'uploads', 'vagina',
64
      'validation', 'validations', 'vid', 'video', 'video-stat', 'videos', 'voice', 'w', 'wank', 'wave',
65
      'webdisk', 'webmail', 'webmaster', 'webrnail', 'whm', 'whoi', 'whois', 'whore', 'wifi', 'wiki',
66
      'wtf', 'ww', 'www', 'www1', 'www2', 'wwww', 'xhtml', 'xhtrnl', 'xml', 'xxx'
67
    ];
68
69
    /**
70
     * Determine if the validation rule passes.
71
     *
72
     * @param  string $attribute
73
     * @param  mixed  $value
74
     *
75
     * @return bool
76
     */
77 3
    public function passes($attribute, $value)
78
    {
79 3
        if (!preg_match('/^[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?$/', $value)) {
80 2
            return false;
81
        }
82
83 3
        if (in_array($value, static::$reserved)) {
84 1
            return false;
85
        }
86
87 3
        return true;
88
    }
89
90
    /**
91
     * Get the validation error message.
92
     *
93
     * @return string
94
     */
95 3
    public function message()
96
    {
97 3
        return 'The :attribute is not available';
98
    }
99
}
100