File::getNextLine()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Facade\FlareClient\Stacktrace;
4
5
use SplFileObject;
6
7
class File
8
{
9
    /** @var \SplFileObject */
10
    private $file;
11
12
    public function __construct(string $path)
13
    {
14
        $this->file = new SplFileObject($path);
15
    }
16
17
    public function numberOfLines(): int
18
    {
19
        $this->file->seek(PHP_INT_MAX);
20
21
        return $this->file->key() + 1;
22
    }
23
24
    public function getLine(int $lineNumber = null): string
25
    {
26
        if (is_null($lineNumber)) {
27
            return $this->getNextLine();
28
        }
29
30
        $this->file->seek($lineNumber - 1);
31
32
        return $this->file->current();
33
    }
34
35
    public function getNextLine(): string
36
    {
37
        $this->file->next();
38
39
        return $this->file->current();
40
    }
41
}
42