/** * @see DirectoryCalculator::calculateDirectory */ public function calculateDirectory(Identifiable $obj) { if (!$obj instanceof UniversallyIdentifiable) { throw new LogicException('Expected an universally identifiable'); } if (!preg_match($this->uuidRegex, $obj->getUuid())) { throw new LogicException('Expected a valid UUID'); } $uuid = str_replace('-', '', $obj->getUuid()); $dirs = []; for ($x = 0; $x < strlen($uuid); $x += 2) { $dirs[] = substr($uuid, $x, 2); } return implode(DIRECTORY_SEPARATOR, $dirs); }