Conditions | 4 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
35 | public function getContents() |
||
36 | { |
||
37 | // Make sure file exists |
||
38 | if (!file_exists($this->getFrom()) || !is_readable($this->getFrom())) { |
||
39 | throw new ContentsException(sprintf( |
||
40 | 'Can not read from "%s"', |
||
41 | $this->getFrom() |
||
42 | )); |
||
43 | } |
||
44 | |||
45 | $contents = file_get_contents($this->getFrom()); |
||
46 | |||
47 | if ($contents === false) { |
||
48 | throw new ContentsException(sprintf( |
||
49 | 'Could not read from "%s"', |
||
50 | $this->getFrom() |
||
51 | )); |
||
52 | } |
||
53 | |||
54 | return $contents; |
||
55 | } |
||
56 | |||
80 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.