Completed
Push — master ( 9994ee...95fa60 )
by Konstantin
03:22
created

ValidationTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 38
c 1
b 0
f 1
ccs 8
cts 8
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isCyrillic() 0 4 1
A isLatin() 0 4 1
A isText() 0 4 1
A isInteger() 0 4 1
1
<?php
2
namespace phrlog\FormHelper;
3
4
/**
5
 * Class ValidationTrait
6
 * @package FormHelper
7
 */
8
trait ValidationTrait
9
{
10
    /**
11
     * @param $word
12
     * @return bool
13
     */
14 3
    public static function isCyrillic($word)
15
    {
16 3
        return (bool) preg_match("/[\p{Cyrillic}]/ui", $word);
17
    }
18
19
    /**
20
     * @param $word
21
     * @return bool
22
     */
23 3
    public static function isLatin($word)
24
    {
25 3
        return (bool) preg_match("/[\p{Latin}]/ui", $word);
26
    }
27
28
    /**
29
     * @param $word
30
     * @return bool
31
     */
32 5
    public static function isText($word)
33
    {
34 5
        return (bool) preg_match("/(\p{Latin}+|[\p{Cyrillic}]+)$/u", $word);
35
    }
36
37
    /**
38
     * @param $digit
39
     * @return bool
40
     */
41 3
    public static function isInteger($digit)
42
    {
43 3
        return (bool) preg_match("/^\d+$/", $digit);
44
    }
45
}