File   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A toTexts() 0 5 1
A getFileContent() 0 3 1
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