RegExp::getAllMatch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: vincenzo.ciaccio
5
 * Date: 29/10/2015
6
 * Time: 16:58
7
 */
8
9
namespace App\Lib\Helpers;
10
11
12
/**
13
 * Class RegExp
14
 * @package App\Lib\Helpers
15
 */
16
class RegExp
17
{
18
    /**
19
     * @param $regexp
20
     * @param $target
21
     * @return null
22
     */
23
    public static function getFirstMatch($regexp, $target)
24
	{
25
		preg_match_all($regexp, $target, $matches);
26
		$match = array_key_exists(0,$matches[1]) ? $matches[1][0] : null;
27
		return $match;
28
	}
29
30
    /**
31
     * @param $regexp
32
     * @param $target
33
     * @return null
34
     */
35
    public static function getAllMatch($regexp, $target)
36
	{
37
		$matches = null;
38
		preg_match_all($regexp, $target, $matches);
39
		return $matches;
40
	}
41
42
}