Passed
Push — master ( 707ddf...aa8b2f )
by Sebastian
04:56
created

ConvertHelper_URLFinder_Detector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 2
b 0
f 0
dl 0
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processString() 0 7 1
A getMatches() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils;
6
7
abstract class ConvertHelper_URLFinder_Detector
8
{
9
    const RUN_BEFORE = 'before';
10
    const RUN_AFTER = 'after';
11
12
    /**
13
     * @var string[]
14
     */
15
    private $matches = array();
16
17
    public function processString(string $subject) : string
18
    {
19
        $subject = $this->filterSubject($subject);
20
21
        $this->matches = $this->detect($subject);
22
23
        return str_replace($this->matches, ' ', $subject);
24
    }
25
26
    /**
27
     * @return string[]
28
     */
29
    public function getMatches() : array
30
    {
31
        return $this->matches;
32
    }
33
34
    abstract public function getRunPosition() : string;
35
36
    abstract public function isValidFor(string $subject) : bool;
37
38
    abstract protected function filterSubject(string $subject) : string;
39
40
    /**
41
     * @param string $subject
42
     * @return string[]
43
     */
44
    abstract protected function detect(string $subject) : array;
45
}
46