IgnoreEntrySearcher   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 39
rs 10
ccs 12
cts 12
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A search() 0 16 4
A __construct() 0 4 1
1
<?php
2
3
namespace IgnoreFiles\Service;
4
5
use IgnoreFiles\Infrastructure\Disk\FileReader;
6
7
class IgnoreEntrySearcher
8
{
9
    /**
10
     * @var FileReader
11
     */
12
    private $fileReader;
13
14
    /**
15
     * @param string $entry
16
     *
17
     * @return bool
18
     */
19 10
    public function search($entry)
20
    {
21 10
        $data = TrimContentTransformer::trim($this->fileReader->read());
22
23 10
        if (in_array($entry, $data)) {
24 2
            return true;
25
        }
26
27 8
        foreach ($data as $item) {
28 7
            if (0 === strpos($entry, $item)) {
29 4
                return true;
30
            }
31 8
        }
32
33 4
        return false;
34
    }
35
36
    /**
37
     * IgnoreEntrySearcher constructor.
38
     *
39
     * @param FileReader $fileReader
40
     */
41 10
    public function __construct(FileReader $fileReader)
42
    {
43 10
        $this->fileReader = $fileReader;
44 10
    }
45
}
46