Completed
Push — master ( b0a705...b889cd )
by raphael
01:13
created

Pattern::getPattern()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Rap2hpoutre\LaravelLogViewer;
4
5
/**
6
 * Class Pattern
7
 * @property array patterns
8
 * @package Rap2hpoutre\LaravelLogViewer
9
 */
10
11
class Pattern
12
{
13
14
    /**
15
     * @var array
16
     */
17
    private $patterns = [
18
        'logs' => '/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}([\+-]\d{4})?\].*/',
19
        'current_log' => [
20
            '/^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}([\+-]\d{4})?)\](?:.*?(\w+)\.|.*?)',
21
            ': (.*?)( in .*?:[0-9]+)?$/i'
22
        ],
23
        'files' => '/\{.*?\,.*?\}/i',
24
    ];
25
26
    /**
27
     * @return array
28
     */
29
    public function all()
30
    {
31
        return array_keys($this->patterns);
32
    }
33
34
    /**
35
     * @param $pattern
36
     * @param null $position
37
     * @return string pattern
38
     */
39
    public function getPattern($pattern, $position = null)
40
    {
41
        if ($position != null) {
42
            return $this->patterns[$pattern][$position];
43
        }
44
        return $this->patterns[$pattern];
45
        
46
    }
47
48
}