Prefix   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A match() 0 9 3
1
<?php
2
namespace exussum12\CoverageChecker\FileMatchers;
3
4
use exussum12\CoverageChecker\FileMatcher;
5
use exussum12\CoverageChecker\Exceptions\FileNotFound;
6
7
/**
8
 * Class Prefix
9
 * @package exussum12\CoverageChecker\FileMatchers
10
 */
11
class Prefix implements FileMatcher
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $prefix;
17
18
    /**
19
     * Prefix constructor.
20
     * @param string $prefix
21
     */
22
    public function __construct(string $prefix)
23
    {
24
        $this->prefix = $prefix;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function match(string $needle, array $haystack): string
31
    {
32
        foreach ($haystack as $file) {
33
            if ($file == $this->prefix . $needle) {
34
                return $file;
35
            }
36
        }
37
38
        throw new FileNotFound();
39
    }
40
}
41