Util   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A containsNotUrl() 0 4 1
A containsUrl() 0 12 3
1
<?php
2
3
namespace Rj\FrontendBundle\Util;
4
5
class Util
6
{
7
    /**
8
     * @param string $subject
9
     *
10
     * @return bool
11
     */
12 7
    public static function containsNotUrl($subject)
13
    {
14 7
        return static::containsUrl($subject, true);
15
    }
16
17
    /**
18
     * @param string $subject
19
     * @param bool   $negate
20
     *
21
     * @return bool
22
     */
23 29
    public static function containsUrl($subject, $negate = false)
24
    {
25 29
        if (is_string($subject)) {
26 2
            $subject = [$subject];
27
        }
28
29 29
        $flags = $negate ? PREG_GREP_INVERT : null;
30
31 29
        $result = preg_grep('|^(https?:)?//|', $subject, $flags);
32
33 29
        return !empty($result);
34
    }
35
}
36