File::getFileContent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpSpellcheck\Source;
6
7
use PhpSpellcheck\Text;
8
9
class File implements SourceInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    private $filePath;
15
16
    public function __construct(string $filePath)
17
    {
18
        $this->filePath = $filePath;
19
    }
20
21
    /**
22 5
     * @param array<mixed> $context
23
     *
24 5
     * @return iterable<Text>
25 5
     */
26 5
    public function toTexts(array $context = []): iterable
27
    {
28
        $context['filePath'] = \Safe\realpath($this->filePath);
29
30 5
        yield new Text($this->getFileContent(), $context);
31 1
    }
32 5
33 5
    private function getFileContent(): string
34 5
    {
35 5
        return \Safe\file_get_contents($this->filePath);
36 1
    }
37
}
38