StringUtils::extractUrls()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Oryzone PHPoAuthUserData package <https://github.com/Oryzone/PHPoAuthUserData>.
5
 *
6
 * (c) Oryzone, developed by Luciano Mammino <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace OAuth\UserData\Utils;
13
14
/**
15
 * Class StringUtils
16
 * @package OAuth\UserData\Utils
17
 */
18
class StringUtils
19
{
20
21
    /**
22
     * Extract urls from a string
23
     *
24
     * @param  string $string
25
     * @return array
26
     */
27
    public static function extractUrls($string)
28
    {
29
        preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|(?:[^[:punct:]\s]|/))#', $string, $match);
30
31
        return isset($match[0]) ? $match[0] : array();
32
    }
33
}
34