IgnoreEntrySearcher::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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