File   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A numberOfLines() 0 6 1
A getLine() 0 10 2
A getNextLine() 0 6 1
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