Completed
Pull Request — master (#18)
by Paulo Rodrigues
02:23
created

Util::hasQuestionHelper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
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