Elgg  Version 1.11
File.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Filesystem;
3 
11 class File {
12 
14  private $directory;
15 
17  private $path;
18 
25  public function __construct(Directory $directory, $path) {
26  $this->directory = $directory;
27  $this->path = $path;
28  }
29 
33  public function exists() {
34  return $this->directory->isFile($this->path);
35  }
36 
40  public function getBasename() {
41  return pathinfo($this->path, PATHINFO_BASENAME);
42  }
43 
49  public function getContents() {
50  return $this->directory->getContents($this->path);
51  }
52 
56  public function getExtension() {
57  return pathinfo($this->path, PATHINFO_EXTENSION);
58  }
59 
67  public function includeFile() {
68  return $this->directory->includeFile($this->path);
69  }
70 
72  public function __toString() {
73  return $this->path;
74  }
75 }
A simple directory abstraction.
Definition: Directory.php:11
__construct(Directory $directory, $path)
Constructor.
Definition: File.php:25
$CONFIG path
The full path where Elgg is installed.
Definition: config.php:66
getContents()
Get the text content of this file.
Definition: File.php:49
Represents a file that may or may not actually exist.
Definition: File.php:11
includeFile()
Do a PHP include of the file and return the result.
Definition: File.php:67