DateFilter::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
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 haciendo que sea fecha
20
 *
21
 * @category   Kumbia
22
 * @package    Filter
23
 * @subpackage BaseFilter
24
 */
25
class DateFilter implements FilterInterface
26
{
27
28
    /**
29
     * Ejecuta el filtro
30
     *
31
     * @param string $s
32
     * @param array $options
33
     * @return string
34
     */
35
    public static function execute($s, $options)
36
    {
37
        $patron = '/(19|20)(\d{2})-(\d{1,2})-(\d{1,2})/';
38
        if (preg_match($patron, $s, $regs)) {
39
            return $regs[0];
40
        } else {
41
            return "";
42
        }
43
    }
44
45
}