Elgg  Version master
ClassMap.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg;
4 
10 class ClassMap {
11 
15  protected $map = [];
16 
20  protected $altered = false;
21 
29  public function getPath($class) {
30  if ($class[0] === '\\') {
31  $class = substr($class, 1);
32  }
33 
34  return $this->map[$class] ?? '';
35  }
36 
45  public function setPath($class, $path) {
46  if ($class[0] === '\\') {
47  $class = substr($class, 1);
48  }
49 
50  if (!isset($this->map[$class]) || $this->map[$class] !== $path) {
51  $this->map[$class] = $path;
52  $this->altered = true;
53  }
54 
55  return $this;
56  }
57 
63  public function getAltered() {
64  return $this->altered;
65  }
66 
74  public function setAltered($altered) {
75  $this->altered = (bool) $altered;
76  return $this;
77  }
78 
84  public function getMap() {
85  return $this->map;
86  }
87 
96  public function setMap(array $map) {
97  $this->map = $map;
98  return $this;
99  }
100 
109  public function mergeMap(array $map) {
110  $this->map = array_merge($this->map, $map);
111  return $this;
112  }
113 }
getAltered()
Was this map altered by the class loader?
Definition: ClassMap.php:63
setMap(array $map)
Set the full map.
Definition: ClassMap.php:96
getMap()
Get the full map.
Definition: ClassMap.php:84
getPath($class)
Get the path for a class/interface/trait.
Definition: ClassMap.php:29
mergeMap(array $map)
Merge a class map with the current map.
Definition: ClassMap.php:109
setAltered($altered)
Set the altered flag.
Definition: ClassMap.php:74
$class
Definition: summary.php:44
A map of class names to absolute file paths.
Definition: ClassMap.php:10
$path
Definition: details.php:70
setPath($class, $path)
Set the path for a class/interface/trait, and mark map as altered.
Definition: ClassMap.php:45