Completed
Push — master ( 1798f9...8b113a )
by Paulo Rodrigues
07:08
created

Util   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 0
cbo 0
dl 0
loc 30
ccs 10
cts 10
cp 1
rs 10

4 Methods

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