Completed
Push — master ( e54ccb...52bc20 )
by Konstantin
03:38
created

ValidationTrait::isText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
c 1
b 0
f 1
ccs 2
cts 2
cp 1
rs 10
nc 1
cc 1
eloc 2
nop 1
crap 1
1
<?php
2
namespace 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
}