GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Regex::getRules()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 3
eloc 8
nc 3
nop 2
1
<?php
2
/**
3
 * Regex
4
 *
5
 * @category  AcsiWidget\Renderer\JqueryValidate\Rule
6
 * @package   AcsiWidget\Renderer\JqueryValidate\Rule
7
 * @copyright 2016 ACSI Holding bv (http://www.acsi.eu)
8
 * @version   SVN: $Id: $
9
 */
10
11
namespace StrokerForm\Renderer\JqueryValidate\Rule;
12
13
use Zend\Form\ElementInterface;
14
use Zend\Validator\ValidatorInterface;
15
use Zend\Validator\Regex as RegexValidator;
16
17
class Regex extends AbstractRule
18
{
19
20
    /**
21
     * Get the validation rules
22
     *
23
     * @param ValidatorInterface $validator
24
     * @param ElementInterface $element
25
     * @return array
26
     */
27
    public function getRules(ValidatorInterface $validator, ElementInterface $element = null)
28
    {
29
        /**@var RegexValidator $validator */
30
        $pattern = $validator->getPattern();
31
        $modifier = '';
32
33
        // Only i, m and g modifier are compatible with Ecmascript regexp
34
        if (preg_match('/\/(.*)\/([img])?/', $pattern, $matches)) {
35
            $pattern = $matches[1];
36
            if (isset($matches[2])) {
37
                $modifier = $matches[2];
38
            }
39
        }
40
41
        return ['regex' => [$pattern, $modifier]];
42
    }
43
44
    /**
45
     * Get the validation message
46
     *
47
     * @param  ValidatorInterface $validator
48
     * @return array
49
     */
50
    public function getMessages(ValidatorInterface $validator)
51
    {
52
        return ['regex' => $this->translateMessage('Field does not match expected pattern')];
53
    }
54
55
    /**
56
     * @param ValidatorInterface $validator
57
     * @return bool
58
     */
59
    public function canHandle(ValidatorInterface $validator)
60
    {
61
        return $validator instanceof RegexValidator;
62
    }
63
}
64