Completed
Pull Request — master (#2252)
by ྅༻ Ǭɀħ
02:22
created

CachedFileReader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
/**
3
 * This file is part of the POMO package.
4
 *
5
 * @copyright 2014 POMO
6
 * @license GPL
7
 */
8
9
namespace POMO\Streams;
10
11
/**
12
 * Reads the contents of the file in the beginning.
13
 *
14
 * @author Danilo Segan <[email protected]>
15
 */
16
class CachedFileReader extends StringReader
17
{
18
    public function __construct($filename)
19
    {
20
        parent::__construct();
21
        $this->_str = file_get_contents($filename);
22
        if (false === $this->_str) {
23
            return false;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
24
        }
25
        $this->_pos = 0;
0 ignored issues
show
Bug introduced by
The property _pos does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
    }
27
}
28