EntityFieldRegexpFilter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 26
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorMessage() 0 3 1
A validate() 0 3 1
A getSupportedOperator() 0 3 1
1
<?php
2
3
namespace Mdiyakov\DoctrineSolrBundle\Filter\Field;
4
5
class EntityFieldRegexpFilter extends EntityFieldFilter
6
{
7
8
    /**
9
     * @param mixed $value
10
     * @return bool
11
     */
12
    public function validate($value)
13
    {
14
        return (bool) preg_match($this->getEntityFieldValue(), $value);
15
    }
16
17
    /**
18
     * @return string
19
     */
20
    public function getErrorMessage()
21
    {
22
        return sprintf('The value of %s have to be matched with regexp %s', $this->getEntityFieldName(),  (string) $this->getEntityFieldValue());
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    public function getSupportedOperator()
29
    {
30
        return 'regexp';
31
    }
32
}