Completed
Push — dev ( b65692...5bc640 )
by Marc
13:01
created

Ip::input()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php namespace Mascame\Artificer\Fields\Types;
2
3
use Form;
4
5
class Ip extends Text
6
{
7
8
    public function input()
9
    {
10
        if (! isset($this->attributes['pattern'])) {
11
            $patterns = [
12
                '((^|:)([0-9a-fA-F]{0,4})){1,8}$|((^|\.)((25[0-5])', // v6
13
                '(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$' // v4
14
            ];
15
16
            $this->attributes['pattern'] = join('|', $patterns);
17
        }
18
19
        return parent::input();
20
    }
21
}