Completed
Push — l10n_master ( 453465...12070f )
by Jeroen
15:21 queued 08:31
created

URLValidator::isEmailAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Kunstmaan\NodeBundle\Validation;
4
5
trait URLValidator
6
{
7
    /**
8
     * Check if given text is e-mail address.
9
     */
10 3
    public function isEmailAddress($link)
11
    {
12 3
        return filter_var($link, FILTER_VALIDATE_EMAIL);
13
    }
14
15
    /**
16
     * Check if given text is an internal link.
17
     */
18 7
    public function isInternalLink($link)
19
    {
20 7
        preg_match_all("/\[(([a-z_A-Z\.]+):)?NT(\d+)\]/", $link, $matches, PREG_SET_ORDER);
21
22 7
        return \count($matches) > 0;
23
    }
24
25
    /**
26
     * Check if given text is an internal media link.
27
     */
28 7
    public function isInternalMediaLink($link)
29
    {
30 7
        preg_match_all("/\[(([a-z_A-Z]+):)?M(\d+)\]/", $link, $matches, PREG_SET_ORDER);
31
32 7
        return \count($matches) > 0;
33
    }
34
}
35