Ipv4Filter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 9 2
1
<?php
2
/**
3
 * KumbiaPHP web & app Framework
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.
9
 *
10
 * @category   Kumbia
11
 * @package    Filter
12
 * @subpackage BaseFilter
13
 *
14
 * @copyright  Copyright (c) 2005 - 2019 KumbiaPHP Team (http://www.kumbiaphp.com)
15
 * @license    https://github.com/KumbiaPHP/KumbiaPHP/blob/master/LICENSE   New BSD License
16
 */
17
18
/**
19
 * Filtra una cadena para que sea IPv4
20
 *
21
 * @category   Kumbia
22
 * @package    Filter
23
 * @subpackage BaseFilter
24
 */
25
class Ipv4Filter implements FilterInterface
26
{
27
28
    /**
29
     * Ejecuta el filtro
30
     *
31
     * @param string $value
32
     * @param array $options
33
     * @return string
34
     */
35
    public static function execute($value, $options)
36
    {
37
        $patron = '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/';
38
        if (preg_match($patron, $value, $regs)) {
39
            return $regs[0];
40
        } else {
41
            return '';
42
        }
43
    }
44
45
}
46