Completed
Pull Request — master (#18)
by Paulo Rodrigues
02:23
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 12
cts 12
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 30
    public static function hasQuestionHelper()
13
    {
14 30
        return class_exists('Symfony\Component\Console\Question\Question');
15
    }
16
17 14
    public static function containsNotUrl($subject)
18
    {
19 14
        return static::containsUrl($subject, true);
20
    }
21
22 56
    public static function containsUrl($subject, $negate = false)
23
    {
24 56
        if (is_string($subject)) {
25 4
            $subject = array($subject);
26
        }
27
28 56
        $flags = $negate ? PREG_GREP_INVERT : null;
29
30 56
        $result = preg_grep('|^(https?:)?//|', $subject, $flags);
31
32 56
        return !empty($result);
33
    }
34
}
35