Completed
Pull Request — master (#26)
by Paulo Rodrigues
04:47
created

Util   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0
ccs 9
cts 12
cp 0.75

4 Methods

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