Elgg  Version 6.1
EntityDirLocator.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg;
4 
6 
18 
22  const BUCKET_SIZE = 5000;
23 
27  protected $guid;
28 
36  public function __construct(int $guid) {
37  if ($guid < 1) {
38  throw new RangeException('"guid" must be greater than 0');
39  }
40 
41  $this->guid = $guid;
42  }
43 
51  public function getPath(): string {
52  $bound = $this->getLowerBucketBound($this->guid);
53 
54  return "{$bound}/{$this->guid}/";
55  }
56 
62  public function __toString() {
63  return $this->getPath();
64  }
65 
73  private function getLowerBucketBound(int $guid): int {
74  return (int) max(floor($guid / self::BUCKET_SIZE) * self::BUCKET_SIZE, 1);
75  }
76 }
Exception thrown to indicate range errors during program execution.
__construct(int $guid)
Find an entity&#39;s data dir.
getPath()
Construct a file path matrix for an entity.
Locate the relative path of an entity&#39;s data dir.
$guid
Reset an ElggUpgrade.
Definition: reset.php:6
__toString()
String casting magic method.